-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3510 from semgrep/merge-develop-to-release
Merge Develop into Release
- Loading branch information
Showing
56 changed files
with
995 additions
and
1,341 deletions.
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
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 |
---|---|---|
@@ -1,17 +1,65 @@ | ||
# | ||
# Check rule validity and check that semgrep finds the expected findings. | ||
# See https://semgrep.dev/docs/writing-rules/testing-rules for more info. | ||
# | ||
# The semgrep repo also runs this as part of its CI for consistency. | ||
# The semgrep repo (and now semgrep-pro repo) also runs those tests as part | ||
# of its CI for consistency. | ||
# | ||
.PHONY: test | ||
test: | ||
$(MAKE) validate | ||
$(MAKE) test-only | ||
|
||
.PHONY: validate | ||
validate: | ||
./scripts/run-tests validate | ||
# Use the SEMGREP env variable to specify a non-standard semgrep command | ||
SEMGREP ?= semgrep | ||
|
||
.PHONY: test-only | ||
#old: pysemgrep --test was also using flags below but not needed | ||
# --test-ignore-todo --strict --disable-version-check --metrics=off --verbose | ||
test-only: | ||
./scripts/run-tests test | ||
$(SEMGREP) test --pro . | ||
|
||
# TODO: semgrep validate use a different targeting than 'semgrep test' | ||
# so we unfortunately need this whitelist of dirs because it reports | ||
# errors on stats/ and scripts/ (and .github/workflows/) files otherwise | ||
# (we also skip libsonnet/ and trusted_python/ which do not contain rules) | ||
LANG_DIRS=\ | ||
bash \ | ||
c \ | ||
clojure \ | ||
csharp \ | ||
dockerfile \ | ||
generic \ | ||
go \ | ||
html \ | ||
java \ | ||
javascript \ | ||
json \ | ||
kotlin \ | ||
ocaml \ | ||
php \ | ||
python \ | ||
ruby \ | ||
rust \ | ||
scala \ | ||
solidity \ | ||
swift \ | ||
terraform \ | ||
typescript \ | ||
yaml | ||
PRO_DIRS=apex elixir | ||
OTHER_DIRS=ai problem-based-packs | ||
DIRS=$(LANG_DIRS) $(PRO_DIRS) $(OTHER_DIRS) | ||
|
||
.PHONY: validate | ||
#old: pysemgrep --validate was also using the flags below but not needed | ||
# --strict --disable-version-check --metrics=off --verbose | ||
validate: | ||
$(SEMGREP) validate --pro $(DIRS) | ||
|
||
.PHONY: test-oss-only | ||
test-oss-only: | ||
@for dir in $(LANG_DIRS) $(OTHER_DIRS); do \ | ||
echo "processing $$dir"; \ | ||
$(SEMGREP) test $$dir; \ | ||
done |
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
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 @@ | ||
FROM docker:latest | ||
|
||
WORKDIR /app | ||
|
||
# ruleid: dockerfile-dockerd-socket-mount | ||
VOLUME /var/run/docker.sock:/var/run/docker.sock | ||
|
||
# ok: dockerfile-dockerd-socket-mount | ||
VOLUME ./app/main.py:/main.py | ||
|
||
CMD ["docker", "images"] |
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,36 @@ | ||
rules: | ||
- id: dockerfile-dockerd-socket-mount | ||
message: >- | ||
The Dockerfile(image) mounts docker.sock to the container which may allow an attacker already inside of the container | ||
to escape container and execute arbitrary commands on the host machine. | ||
languages: | ||
- dockerfile | ||
- yaml | ||
severity: ERROR | ||
metadata: | ||
cwe: | ||
- "CWE-862: Missing Authorization" | ||
- "CWE-269: Improper Privilege Management" | ||
confidence: HIGH | ||
likelihood: MEDIUM | ||
impact: HIGH | ||
subcategory: | ||
- audit | ||
technology: | ||
- dockerfile | ||
category: security | ||
references: | ||
- https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html | ||
- https://redfoxsec.com/blog/insecure-volume-mounts-in-docker/ | ||
- https://blog.quarkslab.com/why-is-exposing-the-docker-socket-a-really-bad-idea.html | ||
pattern-either: | ||
- patterns: | ||
- pattern: VOLUME $X | ||
- metavariable-regex: | ||
metavariable: $X | ||
regex: "/var/run/docker.sock" | ||
- patterns: | ||
- pattern-regex: '- "/var/run/docker.sock:.*"' | ||
- pattern-inside: | | ||
volumes: | ||
... |
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
Oops, something went wrong.