shieldenv 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
shieldenv/__init__.py ADDED
@@ -0,0 +1,6 @@
1
+ """ShieldEnv: fast secret scanning for repositories and CI pipelines."""
2
+
3
+ from .scanner import Finding, ScanResult, scan_path
4
+
5
+ __all__ = ["Finding", "ScanResult", "scan_path"]
6
+ __version__ = "1.0.0"
shieldenv/cli.py ADDED
@@ -0,0 +1,204 @@
1
+ import codecs
2
+ import json
3
+ import os
4
+ import shlex
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ import click
9
+
10
+ from .scanner import scan_path
11
+
12
+
13
+ def _configure_utf8_stream(stream):
14
+ """Use UTF-8 for real Windows streams without disrupting Click capture."""
15
+ if sys.platform != "win32":
16
+ return stream
17
+
18
+ reconfigure = getattr(stream, "reconfigure", None)
19
+ if reconfigure is not None:
20
+ try:
21
+ reconfigure(encoding="utf-8", errors="strict")
22
+ return stream
23
+ except (AttributeError, OSError, ValueError):
24
+ pass
25
+
26
+ buffer = getattr(stream, "buffer", None)
27
+ if buffer is not None:
28
+ return codecs.getwriter("utf-8")(buffer, "strict")
29
+ return stream
30
+
31
+
32
+ def _configure_utf8_streams():
33
+ sys.stdout = _configure_utf8_stream(sys.stdout)
34
+ sys.stderr = _configure_utf8_stream(sys.stderr)
35
+
36
+
37
+ def safe_echo(message="", **kwargs):
38
+ try:
39
+ click.echo(message, **kwargs)
40
+ except UnicodeEncodeError:
41
+ fallback = str(message).encode("ascii", "replace").decode("ascii")
42
+ click.echo(fallback, **kwargs)
43
+
44
+
45
+ @click.group()
46
+ def main():
47
+ """ShieldEnv: A local-first security scanner for hardcoded secrets and API keys."""
48
+ _configure_utf8_streams()
49
+
50
+ @main.command()
51
+ @click.option("--path", default=".", help="Root directory to scan for secrets.")
52
+ @click.option("--format", type=click.Choice(["text", "json", "sarif"]), default="text", help="Output format for scan results.")
53
+ @click.option("--verbose", is_flag=True, help="Show ignored paths and scan summary.")
54
+ @click.option("--audit", is_flag=True, help="Include suppression and ignore audit data.")
55
+ def scan(path, format, verbose, audit):
56
+ """Scan codebases, configuration files, and environment files for exposed secrets."""
57
+ if format == "text":
58
+ safe_echo("šŸ›”ļø ShieldEnv: Scanning repository files...")
59
+
60
+ try:
61
+ result = scan_path(path, verbose=verbose or audit)
62
+ except (RuntimeError, ValueError) as exc:
63
+ raise click.ClickException(str(exc)) from exc
64
+ violations = [finding.__dict__ for finding in result.violations]
65
+
66
+ if result.errors:
67
+ for error in result.errors:
68
+ safe_echo(f"āŒ {error}", err=True)
69
+ raise click.exceptions.Exit(2)
70
+
71
+ if format == "sarif":
72
+ safe_echo(json.dumps(_to_sarif(result), indent=2))
73
+ if violations or result.errors:
74
+ raise click.exceptions.Exit(1 if violations else 2)
75
+ return
76
+
77
+ if format == "json":
78
+ payload = violations
79
+ if audit or verbose:
80
+ payload = {
81
+ "findings": violations,
82
+ "suppressed": result.suppressed,
83
+ "ignored": result.ignored,
84
+ "files_scanned": result.files_scanned,
85
+ }
86
+ safe_echo(json.dumps(payload, indent=2))
87
+ if violations:
88
+ raise click.exceptions.Exit(1)
89
+ return
90
+
91
+ if not violations:
92
+ safe_echo("āœ… All clear! No leaked secrets or API keys found.")
93
+ if audit or verbose:
94
+ safe_echo(f"Scanned {result.files_scanned} files.")
95
+ safe_echo(f"Suppressed findings: {len(result.suppressed)}")
96
+ safe_echo(f"Ignored paths: {len(result.ignored)}")
97
+ return
98
+
99
+ safe_echo(f"\nāŒ SECURITY ALERT: Found {len(violations)} potential secret leaks!\n")
100
+
101
+ for v in violations:
102
+ safe_echo(f" • Type: {v['type']}")
103
+ safe_echo(f" File: {v['file']} (Line {v['line']})")
104
+ safe_echo(f" Confidence: {v['confidence']}")
105
+ safe_echo(f" Data: {v['snippet']}")
106
+ safe_echo("-" * 50)
107
+
108
+ if audit or verbose:
109
+ safe_echo(f"\nSuppressed findings: {len(result.suppressed)}")
110
+ safe_echo(f"Ignored paths: {len(result.ignored)}")
111
+ safe_echo(f"Files scanned: {result.files_scanned}")
112
+
113
+ safe_echo("\n🚫 Commit/Build BLOCKED. Remove secrets, use environment variables, or update .shieldignore.")
114
+ raise click.exceptions.Exit(1)
115
+
116
+
117
+ def _to_sarif(result):
118
+ return {
119
+ "version": "2.1.0",
120
+ "$schema": "https://json.schemastore.org/sarif-2.1.0.json",
121
+ "runs": [{
122
+ "tool": {
123
+ "driver": {
124
+ "name": "ShieldEnv",
125
+ "informationUri": "https://github.com/ShieldHQ/shieldenv",
126
+ "rules": [
127
+ {"id": finding.type, "name": finding.type}
128
+ for finding in result.violations
129
+ ],
130
+ }
131
+ },
132
+ "results": [
133
+ {
134
+ "ruleId": finding.type,
135
+ "level": "error" if finding.confidence == "high" else "warning",
136
+ "message": {"text": f"Potential secret detected ({finding.confidence} confidence)."},
137
+ "locations": [
138
+ {
139
+ "physicalLocation": {
140
+ "artifactLocation": {
141
+ "uri": _sarif_uri(finding.file)
142
+ },
143
+ "region": {"startLine": finding.line}
144
+ }
145
+ }
146
+ ]
147
+ }
148
+ for finding in result.violations
149
+ ]
150
+ }]
151
+ }
152
+
153
+
154
+ def _sarif_uri(file_path: str) -> str:
155
+ try:
156
+ normalized = os.path.relpath(file_path)
157
+ except ValueError:
158
+ normalized = file_path
159
+ return Path(normalized).as_posix()
160
+
161
+
162
+ @main.command()
163
+ @click.option("--force", is_flag=True, help="Back up and replace an existing pre-commit hook.")
164
+ def install(force):
165
+ """Automatically install ShieldEnv as a local Git pre-commit hook."""
166
+ git_dir = Path(".git")
167
+ if not git_dir.exists():
168
+ safe_echo("āŒ Error: Not a git repository. Run 'git init' first.")
169
+ raise click.exceptions.Exit(1)
170
+
171
+ hook_path = git_dir / "hooks" / "pre-commit"
172
+ if hook_path.exists() and not force:
173
+ raise click.ClickException(
174
+ f"{hook_path} already exists; use --force to replace it with a backup."
175
+ )
176
+
177
+ if hook_path.exists():
178
+ backup_path = hook_path.with_name("pre-commit.shieldenv-backup")
179
+ hook_path.replace(backup_path)
180
+
181
+ if getattr(sys, "frozen", False):
182
+ command = shlex.quote(sys.executable)
183
+ else:
184
+ command = f"{shlex.quote(sys.executable)} -m shieldenv.cli"
185
+ hook_script = f"""#!/bin/sh
186
+ # ShieldEnv automated pre-commit security hook
187
+ exec {command} scan
188
+ """
189
+ try:
190
+ hook_path.parent.mkdir(parents=True, exist_ok=True)
191
+ with open(hook_path, "w", encoding="utf-8") as f:
192
+ f.write(hook_script)
193
+
194
+ # Make executable on Unix/Mac
195
+ if os.name != 'nt':
196
+ hook_path.chmod(0o755)
197
+
198
+ safe_echo("āœ… Successfully installed ShieldEnv git pre-commit hook!")
199
+ except OSError as e:
200
+ safe_echo(f"āŒ Failed to install hook: {e}")
201
+ raise click.exceptions.Exit(1)
202
+
203
+ if __name__ == "__main__":
204
+ main()
shieldenv/config.py ADDED
@@ -0,0 +1,32 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ BUILTIN_IGNORES = {
6
+ "node_modules", "venv", ".venv", "dist", "build", ".next",
7
+ "__pycache__", ".pytest_cache", ".ruff_cache", ".git",
8
+ "package-lock.json", "yarn.lock", "pnpm-lock.yaml"
9
+ }
10
+
11
+ def load_shieldignore(root_dir: Path = Path(".")) -> set[str]:
12
+ ignore_set = set(BUILTIN_IGNORES)
13
+
14
+ def add_entries(ignore_file: Path) -> None:
15
+ if not ignore_file.exists():
16
+ return
17
+ try:
18
+ lines = ignore_file.read_text(encoding="utf-8").splitlines()
19
+ except OSError as exc:
20
+ raise RuntimeError(f"Unable to read ignore file: {ignore_file}") from exc
21
+ for line in lines:
22
+ cleaned = line.strip()
23
+ if cleaned and not cleaned.startswith("#"):
24
+ ignore_set.add(cleaned.strip("/"))
25
+
26
+ # 1. Check local project .shieldignore
27
+ add_entries(root_dir / ".shieldignore")
28
+
29
+ # 2. Check global user-level ignore (~/.shieldignore)
30
+ add_entries(Path.home() / ".shieldignore")
31
+
32
+ return ignore_set
shieldenv/patterns.py ADDED
@@ -0,0 +1,32 @@
1
+ from __future__ import annotations
2
+
3
+ import re
4
+ from dataclasses import dataclass
5
+
6
+
7
+ @dataclass(frozen=True)
8
+ class PatternRule:
9
+ name: str
10
+ pattern: re.Pattern[str]
11
+ confidence: str
12
+
13
+
14
+ PATTERN_RULES = (
15
+ PatternRule("OpenAI API Key", re.compile(r"sk-[a-zA-Z0-9]{32,}", re.IGNORECASE), "high"),
16
+ PatternRule("Anthropic API Key", re.compile(r"sk-ant-[a-zA-Z0-9\-_]{20,}", re.IGNORECASE), "high"),
17
+ PatternRule("Google Gemini / AIza Key", re.compile(r"AIza[0-9A-Za-z\-_]{35}", re.IGNORECASE), "high"),
18
+ PatternRule("GitHub Personal Access Token", re.compile(r"gh[pousr]_[a-zA-Z0-9_]{20,}", re.IGNORECASE), "high"),
19
+ PatternRule("AWS access key", re.compile(r"AKIA[0-9A-Z]{16}"), "high"),
20
+ PatternRule("Azure Storage Key", re.compile(r"DefaultEndpointsProtocol=https?;AccountName=[^;]+;AccountKey=[^;]+", re.IGNORECASE), "high"),
21
+ PatternRule("Stripe Secret Key", re.compile(r"sk_(?:live|test)_[0-9a-zA-Z]{20,}", re.IGNORECASE), "high"),
22
+ PatternRule("Slack Webhook / Token", re.compile(r"xox[baprs]-[0-9a-zA-Z]{10,48}"), "high"),
23
+ PatternRule("Database Connection URL", re.compile(r"(postgres|mysql|mongodb(\+srv)?):\//[^\s]+:[^\s]+@[^\s]+", re.IGNORECASE), "high"),
24
+ PatternRule("JWT", re.compile(r"\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b"), "medium"),
25
+ PatternRule("Generic Private Key", re.compile(r"-----BEGIN (RSA|EC|PRIVATE|OPENSSH) KEY-----"), "high"),
26
+ PatternRule("Generic Secret Assignment", re.compile(
27
+ r"""(?:"?(api_key|secret_key|password|passwd|auth_token|bearer)"?\s*(?:=|:)\s*['"][^'"]{8,200}['"])""",
28
+ re.IGNORECASE,
29
+ ), "medium"),
30
+ )
31
+
32
+ SECRET_PATTERNS = {rule.name: rule.pattern for rule in PATTERN_RULES}
shieldenv/scanner.py ADDED
@@ -0,0 +1,211 @@
1
+ from __future__ import annotations
2
+
3
+ import math
4
+ import re
5
+ from collections import Counter
6
+ from dataclasses import dataclass, field
7
+ from fnmatch import fnmatch
8
+ from pathlib import Path
9
+
10
+ from .config import load_shieldignore
11
+ from .patterns import PATTERN_RULES
12
+
13
+ SECRET_ASSIGNMENT = re.compile(
14
+ r"^\s*(?:(?:export\s+)?(?:const|let|var)\s+)?"
15
+ r"(?P<name>[A-Za-z_][\w.]*)"
16
+ r"(?:\s*:\s*[^=]+)?\s*=\s*(?P<value>.+)$"
17
+ )
18
+
19
+ @dataclass
20
+ class Finding:
21
+ file: str
22
+ line: int
23
+ type: str
24
+ snippet: str
25
+ confidence: str = "medium"
26
+
27
+ @property
28
+ def rule(self) -> str:
29
+ return self.type
30
+
31
+ @dataclass
32
+ class ScanResult:
33
+ violations: list[Finding] = field(default_factory=list)
34
+ files_scanned: int = 0
35
+ errors: list[str] = field(default_factory=list)
36
+ suppressed: list[dict[str, str | int]] = field(default_factory=list)
37
+ ignored: list[str] = field(default_factory=list)
38
+
39
+ @property
40
+ def findings(self) -> list[Finding]:
41
+ return self.violations
42
+
43
+ @property
44
+ def has_secrets(self) -> bool:
45
+ return len(self.violations) > 0
46
+
47
+ EXCLUDE_EXTENSIONS = {
48
+ ".png", ".jpg", ".jpeg", ".ico", ".pdf", ".lock", ".zip", ".tar", ".gz",
49
+ ".pyc", ".woff", ".woff2", ".bin", ".md", ".markdown", ".txt"
50
+ }
51
+
52
+ def calculate_entropy(data: str) -> float:
53
+ """Calculates Shannon entropy to detect randomized strings/secrets."""
54
+ if not data:
55
+ return 0.0
56
+ counts = Counter(data)
57
+ return -sum((count / len(data)) * math.log2(count / len(data)) for count in counts.values())
58
+
59
+ def redact(text: str, match: re.Match[str] | None = None) -> str:
60
+ return "[REDACTED]"
61
+
62
+
63
+ def scan_file_details(file_path: Path) -> tuple[list[Finding], list[dict[str, str | int]]]:
64
+ violations = []
65
+ suppressed = []
66
+ file_str = str(file_path).lower()
67
+
68
+ if ".test." in file_str or ".spec." in file_str or "tests" in file_path.parts:
69
+ return violations, suppressed
70
+
71
+ try:
72
+ with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
73
+ for line_no, line in enumerate(f, 1):
74
+ stripped = line.strip()
75
+ lower_line = stripped.lower()
76
+ suppressed_line = "shieldenv: ignore" in lower_line
77
+
78
+ if stripped.startswith(("#", "//")) or len(stripped) < 8:
79
+ continue
80
+
81
+ if any(term in lower_line for term in ["example", "placeholder", "dummy", "changeme", "your_", "secret123"]):
82
+ continue
83
+
84
+ if "{{" in stripped or "}}" in stripped or "{%" in stripped or "%}" in stripped:
85
+ continue
86
+
87
+ if "${" in stripped or "$(" in stripped:
88
+ continue
89
+
90
+ if (
91
+ any(safe_call in lower_line for safe_call in ["os.getenv", "settings.", "process.env", "config."])
92
+ and "=" in stripped
93
+ and not any(quote in stripped for quote in ["'", '"', "`"])
94
+ ):
95
+ continue
96
+
97
+ if file_path.suffix in {".tsx", ".jsx", ".html", ".vue"}:
98
+ if any(tag in lower_line for tag in ["<h1", "<h3", "<span", "<div", "routerlink", "tabindex", "datakey"]):
99
+ continue
100
+ if "password" in lower_line and not "=" in stripped:
101
+ continue
102
+
103
+ if len(stripped) > 300:
104
+ continue
105
+
106
+ matched = False
107
+ for rule in PATTERN_RULES:
108
+ match = rule.pattern.search(line)
109
+ if match:
110
+ finding = Finding(
111
+ file=str(file_path),
112
+ line=line_no,
113
+ type=rule.name,
114
+ snippet=redact(stripped, match),
115
+ confidence=rule.confidence,
116
+ )
117
+ if suppressed_line:
118
+ suppressed.append({"file": str(file_path), "line": line_no, "reason": "inline suppression"})
119
+ else:
120
+ violations.append(finding)
121
+ matched = True
122
+ break
123
+
124
+ if matched:
125
+ continue
126
+
127
+ assignment = SECRET_ASSIGNMENT.match(stripped)
128
+ if assignment and any(
129
+ word in assignment.group("name").lower()
130
+ for word in ["token", "secret", "password", "api_key", "secret_key"]
131
+ ):
132
+ value = assignment.group("value").strip()
133
+ literal = re.fullmatch(r"""(['"])(.*?)\1""", value)
134
+ if literal:
135
+ val = literal.group(2)
136
+ if len(val) > 20 and calculate_entropy(val) > 4.5:
137
+ finding = Finding(
138
+ file=str(file_path),
139
+ line=line_no,
140
+ type="High-Entropy Secret / Custom Token",
141
+ snippet=redact(stripped),
142
+ confidence="medium",
143
+ )
144
+ if suppressed_line:
145
+ suppressed.append({"file": str(file_path), "line": line_no, "reason": "inline suppression"})
146
+ else:
147
+ violations.append(finding)
148
+ except (OSError, UnicodeError) as exc:
149
+ raise RuntimeError(f"Unable to scan file: {file_path}") from exc
150
+ return violations, suppressed
151
+
152
+
153
+ def scan_file(file_path: Path) -> list[Finding]:
154
+ return scan_file_details(file_path)[0]
155
+
156
+ def scan_path(root_dir=".", verbose=False):
157
+ root_path = Path(root_dir).resolve()
158
+ if not root_path.exists():
159
+ raise ValueError(f"Scan path does not exist: {root_path}")
160
+ if not root_path.is_dir():
161
+ raise ValueError(f"Scan path is not a directory: {root_path}")
162
+
163
+ ignore_list = load_shieldignore(root_path)
164
+ all_violations = []
165
+ errors = []
166
+ suppressed = []
167
+ ignored = []
168
+ files_count = 0
169
+
170
+ for path in root_path.rglob("*"):
171
+ rel_path = path.relative_to(root_path)
172
+ rel_str = rel_path.as_posix()
173
+ if any(_matches_ignore(rel_str, path.is_dir(), ignore) for ignore in ignore_list):
174
+ if verbose:
175
+ ignored.append(rel_str)
176
+ continue
177
+
178
+ if path.is_dir():
179
+ continue
180
+ if path.suffix.lower() in EXCLUDE_EXTENSIONS:
181
+ continue
182
+
183
+ files_count += 1
184
+ try:
185
+ findings, audits = scan_file_details(path)
186
+ all_violations.extend(findings)
187
+ suppressed.extend(audits)
188
+ except RuntimeError as exc:
189
+ errors.append(str(exc))
190
+
191
+ return ScanResult(
192
+ violations=all_violations,
193
+ files_scanned=files_count,
194
+ errors=errors,
195
+ suppressed=suppressed,
196
+ ignored=ignored,
197
+ )
198
+
199
+
200
+ def _matches_ignore(relative_path: str, is_directory: bool, pattern: str) -> bool:
201
+ normalized = pattern.strip().strip("/")
202
+ if not normalized:
203
+ return False
204
+ if "/" not in normalized and "\\" not in normalized:
205
+ return normalized in Path(relative_path).parts
206
+ if fnmatch(relative_path, normalized) or fnmatch(relative_path, f"{normalized}/**"):
207
+ return True
208
+ return is_directory and relative_path == normalized
209
+
210
+ def scan_directory(root_dir="."):
211
+ return [v.__dict__ for v in scan_path(root_dir).violations]
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: shieldenv
3
+ Version: 1.0.0
4
+ Summary: Local-first secret and AI API key leak prevention CLI
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Requires-Dist: click>=8.0.0
9
+ Provides-Extra: dev
10
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
11
+ Requires-Dist: ruff>=0.6.0; extra == "dev"
12
+ Dynamic: license-file
13
+
14
+ # ShieldEnv šŸ›”ļø
15
+ Local-First Secret Scanning & Pre-Commit Guardraill
16
+
17
+ ShieldEnv is an open-source security engine designed to eliminate accidental credential leaks, API key exposures, and compliance violations before code ever hits version control.
18
+
19
+ ### Why Local-First?
20
+ Unlike cloud-based PR scanners that analyze your code after it leaves your machine, ShieldEnv runs entirely local-first. Zero code, environment variables, or tokens ever leave your local environment.
21
+
22
+ ## Features
23
+
24
+ - Regex detection for OpenAI, Anthropic, Google, AWS, GitHub, Slack, database URLs, private keys, and generic secret assignments.
25
+ - Provider rules include confidence levels (`high` or `medium`).
26
+ - Entropy-based detection for literal custom tokens.
27
+ - Built-in filtering for placeholders, environment substitutions, templates, and common generated/UI syntax.
28
+ - Project and user-level `.shieldignore` support.
29
+ - Text, JSON, and SARIF output for local and CI use.
30
+ - Optional Git pre-commit hook installation.
31
+ - Redacted findings that never print complete secret values.
32
+
33
+ ## Installation
34
+
35
+ Create an environment and install ShieldEnv:
36
+
37
+ ```bash
38
+ python -m venv .venv
39
+ source .venv/bin/activate
40
+ python -m pip install -e ".[dev]"
41
+ ```
42
+
43
+ On Windows PowerShell, activate with:
44
+
45
+ ```powershell
46
+ .\.venv\Scripts\Activate.ps1
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ Scan the current repository:
52
+
53
+ ```bash
54
+ shieldenv scan
55
+ ```
56
+
57
+ Scan another path or emit machine-readable JSON:
58
+
59
+ ```bash
60
+ shieldenv scan --path ./src --format json
61
+ ```
62
+
63
+ Generate GitHub Code Scanning-compatible SARIF:
64
+
65
+ ```bash
66
+ shieldenv scan --path . --format sarif > shieldenv.sarif
67
+ ```
68
+
69
+ Use verbose mode to inspect scan coverage and ignored paths:
70
+
71
+ ```bash
72
+ shieldenv scan --verbose
73
+ shieldenv scan --audit --format json
74
+ ```
75
+
76
+ Exit codes:
77
+
78
+ - `0`: no findings and no scan errors.
79
+ - `1`: one or more potential secrets were found.
80
+ - `2`: one or more files could not be read.
81
+
82
+ Install a Git pre-commit hook from the repository root:
83
+
84
+ ```bash
85
+ shieldenv install
86
+ ```
87
+
88
+ ShieldEnv will not overwrite an existing hook unless explicitly requested:
89
+
90
+ ```bash
91
+ shieldenv install --force
92
+ ```
93
+
94
+ With `--force`, an existing hook is saved as `.git/hooks/pre-commit.shieldenv-backup`.
95
+
96
+ ## Ignore rules
97
+
98
+ ShieldEnv skips common dependency, build, cache, and lock-file paths by default. Add a project-level `.shieldignore` at the root being scanned, or a global `~/.shieldignore`, with one rule per line:
99
+
100
+ ```text
101
+ # Exact directory name anywhere in the tree
102
+ generated
103
+
104
+ # Relative path or glob
105
+ backend/app/api/
106
+ frontend/generated/**
107
+ ```
108
+
109
+ Blank lines and lines beginning with `#` are ignored. Use ignore rules carefully: excluded files are not scanned. `--verbose` lists ignored paths so exclusions can be reviewed.
110
+
111
+ To suppress a deliberate test value on one line, use the explicit marker:
112
+
113
+ ```python
114
+ TEST_TOKEN = "not-a-credential" # shieldenv: ignore
115
+ ```
116
+
117
+ Suppressions are recorded in audit JSON output. Keep suppressions rare and review them during code review.
118
+
119
+ ## Development
120
+
121
+ ```bash
122
+ python -m pytest
123
+ ruff check .
124
+ ```
125
+
126
+ ShieldEnv is heuristic-based and should complement, not replace, secret rotation and incident-response procedures. Review findings and maintain project-specific ignore rules for generated code.
127
+
128
+ ShieldEnv cannot guarantee detection of every secret format. It combines provider signatures, structured assignment patterns, and entropy heuristics, so unusual encodings may be missed and generated or identifier-like values may still require review. The scanner intentionally reports findings without exposing full values. Run it in CI on Linux, Windows, and macOS; the included workflow tests Python 3.9 through 3.13.
129
+
130
+ Provider signatures are high-confidence indicators; generic assignments and entropy findings are medium-confidence heuristics. A clean scan means no supported rule matched, not that the repository is guaranteed secret-free. Rotate any credential that may have been exposed, and use code review and repository access controls alongside ShieldEnv.
131
+
132
+ ## License
133
+
134
+ Distributed under the MIT License. See [LICENSE](LICENSE) for details.
@@ -0,0 +1,11 @@
1
+ shieldenv/__init__.py,sha256=BP4OtILr_Rt-YwQOAbnDcbtJA8F9CNi9WxZDFXVUxgY,204
2
+ shieldenv/cli.py,sha256=ecxmHyjEepshMBOZGBO-o9vA9xdEcAtrjCn2VsCySX4,7206
3
+ shieldenv/config.py,sha256=ol8nvwRHblhjAYeub1v5bFYGjMNeuv-5QO0_bK9SVOk,1091
4
+ shieldenv/patterns.py,sha256=Y_rHucD7EBHpaqZi_infU4fwuvJFh0E6UkxGKQ3m86Q,1734
5
+ shieldenv/scanner.py,sha256=6p-F6Gk731AOmfKYSv2oZouuSMsHY4oJkNGaNTfmuek,7774
6
+ shieldenv-1.0.0.dist-info/licenses/LICENSE,sha256=k8hVzpRdT6hN-BNyFgWX5W7836Lg1xqiTTEOpCn2mCE,1103
7
+ shieldenv-1.0.0.dist-info/METADATA,sha256=Qe2ZaD6buhM9fN9bUkNtYY9f96l_KwzErhy6Zk2pSy4,4541
8
+ shieldenv-1.0.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
9
+ shieldenv-1.0.0.dist-info/entry_points.txt,sha256=kH34S_NgK12e3VioywZ1RtmiF8PpEqp2ibbMp4SXb-Q,49
10
+ shieldenv-1.0.0.dist-info/top_level.txt,sha256=3WiMzag7sC5e6ICS0bpZTP390mrIcWjWgNhcE2N85KA,10
11
+ shieldenv-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ shieldenv = shieldenv.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ShieldRunner Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ shieldenv