Skip to content

Fixes secret scanning alerts migration - locations processing and matching #1330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

theztefan
Copy link
Contributor

@theztefan theztefan commented Mar 28, 2025

This PR addresses a bug reported #1331 where Secret Scanning alerts with non-commit locations (e.g., pull_request_comment, issue_title, issue_body) were:

  1. Locations were no being parsed correctly and NullReferenceException exceptions was thrown
  2. The matching between non commit and wiki_commit locations was not correct. The issue was the strict URL comparison logic, which failed when the base URL differed between source and target repository.

Changes Made:

  • Updated BuildSecretScanningAlertLocation method to make it more robust by safely accessing properties when building the object in src/Octoshift/Services/GithubApi.cs
  • Enhanced AreLocationsEqual function in src/Octoshift/Services/SecretScanningAlertService.cs:
    • For commit and wiki_commit locations, the comparison remains strict, checking all relevant fields
    • For all other location types, the comparison now focuses on the unique identifier in the URL (e.g., the comment ID or issue number) by extracting and comparing the final path segment of the URLs.
  • Added tests to ensure proper matching for all non-commit location types and that alerts with matching unique identifiers in URLs are correctly updated in the target repository.
  • Did you write/update appropriate tests
  • Release notes updated (if appropriate)
  • Appropriate logging output
  • Issue linked
  • Docs updated (or issue created)
  • New package licenses are added to ThirdPartyNotices.txt (if applicable)

Copy link

github-actions bot commented Mar 28, 2025

Unit Test Results

  1 files    1 suites   20s ⏱️
880 tests 880 ✅ 0 💤 0 ❌
881 runs  881 ✅ 0 💤 0 ❌

Results for commit 52f79bb.

♻️ This comment has been updated with latest results.

@theztefan theztefan marked this pull request as ready for review March 28, 2025 09:41
theztefan and others added 2 commits April 9, 2025 17:14
Copy link
Contributor

@ArinGhazarian ArinGhazarian left a comment

Choose a reason for hiding this comment

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

Looks good, the only thing is test.output should be removed.

Copy link

Code Coverage

Package Line Rate Branch Rate Complexity Health
gei 81% 73% 596
ado2gh 84% 78% 631
bbs2gh 82% 76% 669
Octoshift 87% 76% 1402
Summary 84% (7217 / 8558) 76% (1687 / 2234) 3298

Copy link
Contributor

@ArinGhazarian ArinGhazarian left a comment

Choose a reason for hiding this comment

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

🎉

@ArinGhazarian
Copy link
Contributor

INT tests are all 🟢 merging now.

@ArinGhazarian ArinGhazarian merged commit 57f0944 into github:main Apr 17, 2025
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants