ci: add semgrep job in the ci workflow - #3869
Conversation
Pull request overviewAdds a Changes:
Reviewed changesPer-file summary
FindingsNon-blocking (nits, follow-ups, suggestions):
Overall the job is well-scoped: digest-pinned container, least-privilege ✅ Approved |
| --config p/trailofbits | ||
| --config p/rust | ||
| --config p/secrets | ||
| --exclude-rule trailofbits.rs.panic-in-function-returning-result.panic-in-function-returning-result |
There was a problem hiding this comment.
We have quite a bit of places where we do this, so decided to exclude it instead of adding annotation to over 20 places.
There was a problem hiding this comment.
Should we maybe annotate those call sites properly as a follow up?
| uses: ./.github/actions/restore-nix-cache | ||
|
|
||
| - name: Run opengrep | ||
| run: nix shell .#opengrep -c bash scripts/run-opengrep.sh |
There was a problem hiding this comment.
nit: we could use cargo-make here, but this is also fine ofc
There was a problem hiding this comment.
Leaving as is as it's marked nit.
Also, I assume you mean nix develop --command cargo make opengrep but that will need to build everything (in case of cache miss, if I understand it correctly) hereas this will be lot more isolated.
| # Upstream publishes standalone signed binaries per platform, no docker image. | ||
| assets = { | ||
| x86_64-linux = { | ||
| name = "opengrep_manylinux_x86"; | ||
| hash = "sha256-msSuu0e6P3sNj8ZBrIdJy2wvJT9hYTGmfZYx4A1L6jM="; | ||
| }; | ||
| aarch64-linux = { | ||
| name = "opengrep_manylinux_aarch64"; | ||
| hash = "sha256-/UASQnLQBggqVZSxmuzuB7Ad1Qkz2K3XpP1cVX0r5fY="; | ||
| }; | ||
| aarch64-darwin = { | ||
| name = "opengrep_osx_arm64"; | ||
| hash = "sha256-NUP8q66dsq5byXSjt1QmNT8KPjaRgbIVfvJ/RoZ5lsg="; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
are we fine with downloading binaries for this one? IIRC we were leaning towards the hard core build everything in nix stuff :)
There was a problem hiding this comment.
I've looked a bit into it now, the ones that we build is different because it's rust tools published in crates.io and we can pin hash and build with locked versions. I don't see any non-rust tool that we build here.
On the other hand, while opengrep publishes their flake, they use opam package manager for OCalm (which is apparently language opengrep is written on). To nixify their opam deps they use opam-nix but somewhere down the dependency graph something's not pinned and it can't be built without --impure:
nix build "github:opengrep/opengrep/v1.25.0?submodules=1#opengrep"
error:
… while calling a functor (an attribute set with a '__functor' attribute)
at «github:opengrep/opengrep/27b5fba1b315fbc63d0fd474d01f5d8235cc86e2»/flake.nix:413:11:
412| pyopengrep = with pythonPackages;
413| buildPythonApplication {
| ^
414| # thanks to @06kellyjac
… while evaluating a branch condition
at «github:nixos/nixpkgs/4bd9165a9165d7b5e33ae57f3eecbcb28fb231c9?narHash=sha256-l/iNYDZ4bGOAFQY2q8y5OAfBBtrDAaPuRQqWaFHVRXM%3D»/pkgs/development/interpreters/python/python-packages-base.nix:32:7:
31| in
32| if lib.isAttrs result then
| ^
33| result
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: [opam-nix] a git dependency without an explicit sha1 is not supported in pure evaluation mode; try with --impure
Maybe we can work around this but not sure it's worth going down the rabbit hole.
There was a problem hiding this comment.
yeah, ocaml makes it much harder here, thank you for taking a look
closes: #594