Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f97ab6d
add PushProtectionBypasses and ScanHistory in secret scanning endpoints
Not-Dhananjay-Mishra Aug 18, 2025
895f152
use timestamp instead of time.Time
Not-Dhananjay-Mishra Aug 18, 2025
3a24cda
change method names
Not-Dhananjay-Mishra Aug 18, 2025
52ce83a
fix comments
Not-Dhananjay-Mishra Aug 18, 2025
9908a2d
add comments to struct and change some name
Not-Dhananjay-Mishra Aug 18, 2025
25437f3
fix comments
Not-Dhananjay-Mishra Aug 18, 2025
317ee25
fix comments
Not-Dhananjay-Mishra Aug 18, 2025
3ba69ca
Merge branch 'master' into feat-3686
Not-Dhananjay-Mishra Aug 18, 2025
4aa75c6
Merge branch 'master' into feat-3686
Not-Dhananjay-Mishra Aug 18, 2025
6f7860e
add omitempty
Not-Dhananjay-Mishra Aug 18, 2025
c7213dc
use omitempty where needed and adjust names
Not-Dhananjay-Mishra Aug 18, 2025
1d091ff
fix responsePushProtectionBypass
Not-Dhananjay-Mishra Aug 18, 2025
6606dd4
Merge branch 'master' into feat-3686
Not-Dhananjay-Mishra Aug 19, 2025
399ec39
Merge branch 'master' into feat-3686
gmlewis Sep 22, 2025
a4badd1
Merge branch 'master' into feat-3686
gmlewis Sep 22, 2025
3ccea73
Merge branch 'master' into feat-3686
gmlewis Sep 22, 2025
d92b8d2
change struct name
Not-Dhananjay-Mishra Sep 30, 2025
7dfdcfd
Merge branch 'master' into feat-3686
Not-Dhananjay-Mishra Sep 30, 2025
82cb264
Merge branch 'master' into feat-3686
Not-Dhananjay-Mishra Oct 1, 2025
cfa6d5e
Merge branch 'master' into feat-3686
Not-Dhananjay-Mishra Oct 7, 2025
71aa241
Merge branch 'google:master' into feat-3686
Not-Dhananjay-Mishra Oct 7, 2025
be5f36d
change context
Not-Dhananjay-Mishra Oct 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change struct name
  • Loading branch information
Not-Dhananjay-Mishra committed Sep 30, 2025
commit d92b8d29dfa789630d582ef1ad121611150efff1
4 changes: 2 additions & 2 deletions github/github-accessors.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions github/github-accessors_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 13 additions & 11 deletions github/secret_scanning.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ type SecretScanningAlertUpdateOptions struct {

// PushProtectionBypassRequest represents the parameters for CreatePushProtectionBypass.
type PushProtectionBypassRequest struct {
// Reason provides a justification for the push protection bypass.
// The reason for bypassing push protection.
// Can be one of: false_positive, used_in_tests, will_fix_later
Reason string `json:"reason"`
// PlaceholderID is an identifier used for the bypass request.
// GitHub Secret Scanning provides you with a unique PlaceholderID associated with that specific blocked push.
Expand All @@ -147,23 +148,23 @@ type SecretsScan struct {
StartedAt *Timestamp `json:"started_at,omitempty"`
}

// CustomPatternScan represents a scan with an associated custom pattern.
type CustomPatternScan struct {
// CustomPatternBackfillScan represents a scan with an associated custom pattern.
type CustomPatternBackfillScan struct {
SecretsScan
PatternSlug *string `json:"pattern_slug,omitempty"`
PatternScope *string `json:"pattern_scope,omitempty"`
}

// SecretScanningHistory is the top-level struct for the secret scanning API response.
type SecretScanningHistory struct {
// SecretScanningScanHistory is the top-level struct for the secret scanning API response.
type SecretScanningScanHistory struct {
// Information on incremental scan performed by secret scanning on the repository.
IncrementalScans []*SecretsScan `json:"incremental_scans,omitempty"`
// Information on backfill scan performed by secret scanning on the repository.
BackfillScans []*SecretsScan `json:"backfill_scans,omitempty"`
// Information on pattern update scan performed by secret scanning on the repository.
PatternUpdateScans []*SecretsScan `json:"pattern_update_scans,omitempty"`
// Information on custom pattern backfill scan performed by secret scanning on the repository.
CustomPatternBackfillScans []*CustomPatternScan `json:"custom_pattern_backfill_scans,omitempty"`
CustomPatternBackfillScans []*CustomPatternBackfillScan `json:"custom_pattern_backfill_scans,omitempty"`
}

// ListAlertsForEnterprise lists secret scanning alerts for eligible repositories in an enterprise, from newest to oldest.
Expand Down Expand Up @@ -347,12 +348,13 @@ func (s *SecretScanningService) CreatePushProtectionBypass(ctx context.Context,
if err != nil {
return nil, nil, err
}
var responsePushProtectionBypass *PushProtectionBypass
resp, err := s.client.Do(ctx, req, &responsePushProtectionBypass)

var pushProtectionBypass *PushProtectionBypass
resp, err := s.client.Do(ctx, req, &pushProtectionBypass)
if err != nil {
return nil, resp, err
}
return responsePushProtectionBypass, resp, nil
return pushProtectionBypass, resp, nil
}

// GetScanHistory fetches the secret scanning history for a given repository.
Expand All @@ -363,15 +365,15 @@ func (s *SecretScanningService) CreatePushProtectionBypass(ctx context.Context,
// GitHub API docs: https://docs.github.com/rest/secret-scanning/secret-scanning#get-secret-scanning-scan-history-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/secret-scanning/scan-history
func (s *SecretScanningService) GetScanHistory(ctx context.Context, owner, repo string) (*SecretScanningHistory, *Response, error) {
func (s *SecretScanningService) GetScanHistory(ctx context.Context, owner, repo string) (*SecretScanningScanHistory, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/secret-scanning/scan-history", owner, repo)

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, nil, err
}

var secretScanningHistory *SecretScanningHistory
var secretScanningHistory *SecretScanningScanHistory
resp, err := s.client.Do(ctx, req, &secretScanningHistory)
if err != nil {
return nil, resp, err
Expand Down
14 changes: 7 additions & 7 deletions github/secret_scanning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,19 +710,19 @@ func TestSecretScanningService_GetScanHistory(t *testing.T) {
t.Errorf("SecretScanning.GetScanHistory returned error: %v", err)
}

startAt1 := Timestamp{time.Date(2025, time.July, 29, 9, 55, 0, 0, time.UTC)}
completeAt1 := Timestamp{time.Date(2025, time.July, 29, 10, 0, 0, 0, time.UTC)}
startAt2 := Timestamp{time.Date(2025, time.July, 29, 9, 0, 0, 0, time.UTC)}
incrementalScanStartAt := Timestamp{time.Date(2025, time.July, 29, 9, 55, 0, 0, time.UTC)}
incrementalScancompleteAt := Timestamp{time.Date(2025, time.July, 29, 10, 0, 0, 0, time.UTC)}
customPatternBackfillScanStartedAt := Timestamp{time.Date(2025, time.July, 29, 9, 0, 0, 0, time.UTC)}

want := &SecretScanningHistory{
want := &SecretScanningScanHistory{
IncrementalScans: []*SecretsScan{
{Type: "incremental", Status: "success", CompletedAt: &completeAt1, StartedAt: &startAt1},
{Type: "incremental", Status: "success", CompletedAt: &incrementalScancompleteAt, StartedAt: &incrementalScanStartAt},
},
BackfillScans: []*SecretsScan{},
PatternUpdateScans: []*SecretsScan{},
CustomPatternBackfillScans: []*CustomPatternScan{
CustomPatternBackfillScans: []*CustomPatternBackfillScan{
{
SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: &startAt2},
SecretsScan: SecretsScan{Type: "custom_backfill", Status: "in_progress", CompletedAt: nil, StartedAt: &customPatternBackfillScanStartedAt},
PatternSlug: Ptr("my-custom-pattern"),
PatternScope: Ptr("organization"),
},
Expand Down