Skip to content

Conversation

Not-Dhananjay-Mishra
Copy link

@Not-Dhananjay-Mishra Not-Dhananjay-Mishra commented Aug 18, 2025

This PR adds support for two new Secret Scanning API endpoints that are currently missing from the go-github library

Implement

POST /repos/{owner}/{repo}/secret-scanning/push-protection-bypasses
GET /repos/{owner}/{repo}/secret-scanning/scan-history

Changes

  • Add CreatePushProtectionBypass method
  • Add GetScanHistory method
  • Made two new struct for PushProtectionBypasses method - PushProtectionBypassRequest and PushProtectionBypass
  • Made three new struct for ScanHistory method - Scan, CustomPatternScan and SecretScanningResponse

Issue - #3686

Copy link

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.14%. Comparing base (ffc5df8) to head (3ccea73).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3687      +/-   ##
==========================================
+ Coverage   91.12%   91.14%   +0.01%     
==========================================
  Files         187      187              
  Lines       16640    16666      +26     
==========================================
+ Hits        15164    15190      +26     
  Misses       1291     1291              
  Partials      185      185              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Not-Dhananjay-Mishra
Copy link
Author

@alexandear Thanks for the suggestions. I have changed the method names. Please let me know if you have any other suggestions.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Not-Dhananjay-Mishra.
This is a good start. Please address the findings and then we should be ready for a second LGTM+Approval from any other contributor to this repo before merging.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Aug 18, 2025
@Not-Dhananjay-Mishra
Copy link
Author

Thanks @gmlewis for the feedback! I have fixed all the findings. Sorry for the extra back and forth code review.

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @Not-Dhananjay-Mishra!
LGTM.
Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@gmlewis
Copy link
Collaborator

gmlewis commented Aug 18, 2025

Just FYI - suddenly I have lost write access to this repo, like in #3689... so I can no longer approve the workflows and need to find out what is going on... this may take some time to resolve... I apologize for the inconvenience.

@gmlewis
Copy link
Collaborator

gmlewis commented Sep 22, 2025

@alexandear - do you now approve this PR for merging?

Comment on lines +350 to +355
var responsePushProtectionBypass *PushProtectionBypass
resp, err := s.client.Do(ctx, req, &responsePushProtectionBypass)
if err != nil {
return nil, resp, err
}
return responsePushProtectionBypass, resp, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be consistent with the rest code in the file:

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


// PushProtectionBypassRequest represents the parameters for CreatePushProtectionBypass.
type PushProtectionBypassRequest struct {
// Reason provides a justification for the push protection bypass.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we enhance the comment from GitHub's docs?

Suggested change
// 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

}

// SecretScanningHistory is the top-level struct for the secret scanning API response.
type SecretScanningHistory struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better:

Suggested change
type SecretScanningHistory struct {
type SecretScanningScanHistory struct {

}

// CustomPatternScan represents a scan with an associated custom pattern.
type CustomPatternScan struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type CustomPatternScan struct {
type CustomPatternBackfillScan struct {

// CustomPatternScan represents a scan with an associated custom pattern.
type CustomPatternScan struct {
SecretsScan
PatternSlug *string `json:"pattern_slug,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check whether the GitHub API returns pattern_slug or pattern_name?

The documentation is confusing:

Image Image

The information in the example and the response differs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it return pattern_slug
image

Comment on lines +713 to +715
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)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we think of better names for these variables?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)}
What do you think of these?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsReview PR is awaiting a review before merging. waiting for reply
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants