-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test targets to call semgrep to tests/Makefile. Integrate those targets with the gerrit validation pipeline. There is no need to integrate with our standard .venv, so we create a tiny dedicated venv to run semgrep. CMK-19530 Change-Id: I0c66c53aa2b70994ab13c3c75661e4e13ff18c33
- Loading branch information
1 parent
086862a
commit 47d546e
Showing
9 changed files
with
618 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.venv |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
load("@rules_uv//uv:pip.bzl", "pip_compile") | ||
load("@rules_uv//uv:venv.bzl", "create_venv") | ||
|
||
exports_files([ | ||
"requirements.txt", | ||
]) | ||
|
||
pip_compile( | ||
name = "requirements_lock", | ||
requirements_in = ":requirements.txt", | ||
requirements_txt = ":requirements_lock.txt", | ||
) | ||
|
||
create_venv( | ||
name = "venv", | ||
destination_folder = "tests/semgrep/.venv", | ||
requirements_txt = ":requirements_lock.txt", | ||
) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Update requirements with: | ||
|
||
``` | ||
bazel run :requirements_lock | ||
``` | ||
|
||
Run semgrep (also creates & updates venv): | ||
|
||
``` | ||
./run-semgrep | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
semgrep==1.93.0 | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
# Create a venv with semgrep installed and run semgrep | ||
|
||
set -e | ||
|
||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
VENV_DIR="$SCRIPT_DIR/.venv" | ||
SEMGREP_EXEC="$VENV_DIR/bin/semgrep" | ||
|
||
bazel run //tests/semgrep:venv | ||
|
||
# shellcheck source=/dev/null | ||
source "$VENV_DIR"/bin/activate | ||
|
||
"$SEMGREP_EXEC" "$@" |