Skip to content

Commit a08dc2f

Browse files
authored
feat(contributors): Support populating scan metadata to results for contributor processing (#401)
# Description To support processing contributors, we want to associate each contribution with the driving scan for billing. - [x] I ran `make setup && make` to update the generated code after editing a `.atd` file (TODO: have a CI check) - [x] I made sure we're still backward compatible with old versions of the CLI. For example, the Semgrep backend need to still be able to *consume* data generated by Semgrep 1.50.0. See https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades Note that the types related to the semgrep-core JSON output or the semgrep-core RPC do not need to be backward compatible! - [N/A] Any accompanying changes in `semgrep-proprietary` are approved and ready to merge once this PR is merged
1 parent aae3e2e commit a08dc2f

7 files changed

+680
-4
lines changed

semgrep_output_v1.atd

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,7 @@ type project_metadata = {
16201620

16211621
}
16221622

1623+
(* Scan metadata generated by the CLI during the scan process. *)
16231624
type scan_metadata = {
16241625
cli_version: version;
16251626
unique_id: uuid; (* client generated uuid for the scan *)
@@ -1745,6 +1746,23 @@ type ci_scan_results = {
17451746
(* this data was originally sent to /complete, but we want to start sending
17461747
* it to /results *)
17471748
?dependencies: ci_scan_dependencies option;
1749+
1750+
(* filled in by the backend to associate scan results with the driving scan*)
1751+
?metadata: ci_scan_metadata option;
1752+
}
1753+
1754+
(* Scan metadata populated by the backend after receiving
1755+
* the scan results from the CLI via POST request to
1756+
* /scans/<int:scan_id>/results
1757+
*)
1758+
type ci_scan_metadata = {
1759+
scan_id: int;
1760+
deployment_id: int;
1761+
repository_id: int; (* stored as int in our app db *)
1762+
repository_ref_id: int; (* stored id for a branch or tag *)
1763+
enabled_products: product list;
1764+
git_commit: sha1 nullable;
1765+
git_ref: string nullable;
17481766
}
17491767

17501768
(* See https://semgrep.dev/docs/usage-limits

semgrep_output_v1.jsonschema

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.proto

Lines changed: 12 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.py

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

semgrep_output_v1.ts

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)