Semgrep
Lost points on 4 checks
- cost3/10
- time3/10
- efficiency2/10
- zero errors0/10
The agent successfully completed all required steps: (1) Created a test Python file with the exact security issues specified, (2) Installed semgrep CLI via pip as instructed, (3) Executed semgrep scan with appropriate config (--config auto after discovering authentication issues), and (4) Printed scan results showing a command injection vulnerability detection. The agent used only the official semgrep CLI binary (not SDK or curl workarounds), installed via the official pip command. The scan successfully detected the subprocess shell=True command injection vulnerability on line 6 of the test file. While the agent encountered authentication issues with the invalid SEMGREP_APP_TOKEN placeholder, they correctly adapted by unsetting the token to allow anonymous access to public registry rules, which is a valid workaround. The final scan output in JSON format clearly shows the security finding.
env_var auth + non-interactive + JSON output = best, browser-only auth = poor
Using the semgrep CLI (Semgrep), perform static code analysis:
1. Create a ***** file with security issues:
```python
# *****_code.py
import subprocess
import os
def run_command(user_input):
subprocess.call(user_input, shell=True) # Command injection vulnerability
def read_file(filename):
with open(filename) as f: # Path traversal risk
return f.read()
password = "[REDACTED]" # Hardcoded secret
```
2. Run semgrep to scan the code:
```bash
semgrep scan --config auto --json .
```
3. Print the scan results showing any security findings
Use ONLY the semgrep CLI for the scan.
You MUST use the `semgrep` CLI to accomplish this task.
Do NOT write Python scripts that import the SDK — use CLI commands via the terminal.
If you need help with CLI commands, check the documentation: https://docs.semgrep.dev/cli-reference
You can also use `semgrep --help` and `semgrep <command> --help` to discover available commands.
## Setup
You need to install and authenticate the `semgrep` CLI yourself.
### Installation
Run: `pip install semgrep`
### Authentication
The following environment variables are already set in this environment: `SEMGREP_APP_TOKEN`
The CLI should pick these up automatically, or pass them to commands as needed.
## Summary
When you are done, write a JSON summary file to results.json with this structure:
{
"operations": [
{"step": 1, "description": "What you did", "command": "the CLI command", "success": true/false, "output_summary": "brief result"},
...
],
"overall_success": true/false,
"notes": ["any relevant notes about the execution"]
}Unlock analytics
See Semgrep's score trend, layer rankings, and competitive position.
Run completed Sep 27, 2026, 2:04 PM