Snyk Warning Guide
Local setup
You should set up Snyk locally and run scans before publishing to GitHub. Requires Node.js/npm and Snyk Code enabled for your organization.
npm install --global snyk
snyk auth
Complete the browser login. In app.snyk.io, select your organization, open
Settings → Snyk Code, and enable Snyk Code.
From the repository root, run:
snyk code test --org=YOUR_ORG_ID
SQL injection warnings in Spark
- Pass SQL values through
argsinstead of inserting CLI input into SQL text. - Choose catalog names from a fixed environment mapping. Keep schemas and table names fixed.
- Use
IDENTIFIER(...)to bind object names. - Define column names and types in code, not CLI arguments.
Example for a Spark job. Replace the catalog, schema, and table names for your project.
ENV_CATALOG = {"qa": "qa_catalog", "prod": "prod_catalog"}
env = parameters["environment"]
if env not in ENV_CATALOG:
raise ValueError("environment must be qa or prod")
table = ".".join((ENV_CATALOG[env], "logs", "requests"))
spark.sql(
"SELECT * FROM IDENTIFIER(:table)",
args={"table": table},
)
File exclusions
For a reviewed exception, add a .snyk file at the repository root:
version: v1.31.0
exclude:
code:
# Reason: document the justification here.
- src/clients/example_client.py
This skips all Snyk Code findings in the file, including future vulnerabilities.