Skip to content

Commit

Permalink
feat(sms): add scm_run_id to scan-create interface (#306)
Browse files Browse the repository at this point in the history
For SMS, we would like to be able to connect a particular Scan object to
the SCM (source control manager) run_id that it is associated with.
Details
[here](https://www.notion.so/semgrep/SMS-Supportability-1273009241a880579e9ae90928391a0e?pvs=4#1313009241a880d79d77eb0d6773ad56).

If we create the SCM run before the scan exists (desirable because there
are actually many steps between us receiving a webhook and a Scan object
getting created, leading to a significant time delay), then when we
create the Scan, we need to know what the SCM run id is in order to
connect it to the Scan and update it as the Scan progresses. This
interface change allows us to pass the SCM run from the CLI to the
backend.

Changes in `semgrep` to follow this PR will actually set this value
based on an environment variable and then send it to the app.

- [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.17.0.
See
https://atd.readthedocs.io/en/latest/atdgen-tutorial.html#smooth-protocol-upgrades
  • Loading branch information
chmccreery authored Nov 1, 2024
1 parent 2d5264d commit 4156333
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 4 deletions.
3 changes: 3 additions & 0 deletions semgrep_output_v1.atd
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,9 @@ type scan_metadata = {
unique_id: uuid; (* client generated uuid for the scan *)
requested_products: product list;
~dry_run: bool; (* from 1.47.0 *)
(* since 1.96.0 *)
(* unique id associated with the scan run in the source control manager (e.g. github or gitlab) *)
?scm_run_id: string option;
}

(* Sent by the CLI to the POST /api/cli/scans to create a scan. *)
Expand Down
3 changes: 2 additions & 1 deletion semgrep_output_v1.jsonschema

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

3 changes: 2 additions & 1 deletion semgrep_output_v1.proto

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

4 changes: 4 additions & 0 deletions semgrep_output_v1.py

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

3 changes: 3 additions & 0 deletions semgrep_output_v1.ts

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

52 changes: 51 additions & 1 deletion semgrep_output_v1_j.ml

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

3 changes: 2 additions & 1 deletion semgrep_output_v1_j.mli

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

0 comments on commit 4156333

Please sign in to comment.