fix: correct advsec_get_alerts secret alert filtering and confidenceLevels default (#1395)#1420
Open
David-Mavrodiev wants to merge 2 commits into
Open
Conversation
…evels default (microsoft#1395) - Do not send onlyDefaultBranch/ref for secret-only queries; they are not applicable to secret alerts and caused false-empty results. - Remove forced onlyDefaultBranch=true default; document remaining defaults and the secret-only caveats. - Fix confidenceLevels default casing (lowercase vs PascalCase enum) that threw a Zod validation error whenever confidenceLevels was omitted. - Document mixed-query caveat: unspecified alertType with onlyDefaultBranch=false can exclude secrets. - Add Zod schema-driven tests covering schema defaults and the omitted-confidenceLevels regression.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1420 +/- ##
=======================================
Coverage ? 92.37%
=======================================
Files ? 19
Lines ? 2189
Branches ? 532
=======================================
Hits ? 2022
Misses ? 80
Partials ? 87
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
nuthanmunaiah
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1395
Summary
advsec_get_alertsdiverged from the Azure DevOps Alerts REST API when querying secret alerts, and carried a latent Zod validation crash. This corrects the request construction for secret alerts, removes/documents the forced defaults, fixes the crash, and adds schema-driven tests.Changes
onlyDefaultBranchandrefare "Not applicable for secret alerts" per the REST API. For an explicitalertType: "Secret"query the tool no longer sends them, so it matches the REST API / Advanced Security UI instead of returning an empty set.onlyDefaultBranch = trueZod default (the service already defaults to true when omitted). Documented the remaining defaults (confidenceLevels,top,orderBy) and the secret-only caveats in the schema.["high","other"]while the schema enum keys are PascalCase["High","Other"], so Zod threwinvalid_enum_valueon any call that omittedconfidenceLevels. Changed the default togetEnumKeys(Confidence)so it stays valid and in sync.alertTypeandonlyDefaultBranch=false(orref), secrets may still be excluded because branch filters cannot be applied per-type in a single request; the descriptions now direct callers to queryalertType: "Secret"to retrieve all secrets.Reported symptoms -> resolution
onlyDefaultBranch=falsefor secrets -> fixed for explicit secret queries.onlyDefaultBranchdefault removed; remaining defaults documented.Tests
confidenceLevelscrash.npx jest: 1000 passed / 18 suites.tsc --noEmit: clean.node scripts/build-validate-tools.js: clean.Note
Not yet verified end-to-end against a live org; all verification is at the request-construction / unit level.