devsecpac 2.0.0__tar.gz

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.
Files changed (40) hide show
  1. devsecpac-2.0.0/PKG-INFO +249 -0
  2. devsecpac-2.0.0/README.md +222 -0
  3. devsecpac-2.0.0/pyproject.toml +58 -0
  4. devsecpac-2.0.0/setup.cfg +4 -0
  5. devsecpac-2.0.0/src/devsec_cli/__init__.py +4 -0
  6. devsecpac-2.0.0/src/devsec_cli/bypass.py +98 -0
  7. devsecpac-2.0.0/src/devsec_cli/ci.py +163 -0
  8. devsecpac-2.0.0/src/devsec_cli/cli.py +431 -0
  9. devsecpac-2.0.0/src/devsec_cli/contracts.py +67 -0
  10. devsecpac-2.0.0/src/devsec_cli/correlator.py +110 -0
  11. devsecpac-2.0.0/src/devsec_cli/discovery.py +129 -0
  12. devsecpac-2.0.0/src/devsec_cli/ingestion.py +140 -0
  13. devsecpac-2.0.0/src/devsec_cli/installer.py +453 -0
  14. devsecpac-2.0.0/src/devsec_cli/remediation.py +63 -0
  15. devsecpac-2.0.0/src/devsec_cli/reporter.py +207 -0
  16. devsecpac-2.0.0/src/devsec_cli/runner.py +68 -0
  17. devsecpac-2.0.0/src/devsec_cli/scanners/__init__.py +1 -0
  18. devsecpac-2.0.0/src/devsec_cli/scanners/base.py +45 -0
  19. devsecpac-2.0.0/src/devsec_cli/scanners/codeql.py +140 -0
  20. devsecpac-2.0.0/src/devsec_cli/scanners/cosign.py +69 -0
  21. devsecpac-2.0.0/src/devsec_cli/scanners/dast.py +127 -0
  22. devsecpac-2.0.0/src/devsec_cli/scanners/docker.py +92 -0
  23. devsecpac-2.0.0/src/devsec_cli/scanners/iac.py +170 -0
  24. devsecpac-2.0.0/src/devsec_cli/scanners/k8s_audit.py +132 -0
  25. devsecpac-2.0.0/src/devsec_cli/scanners/kyverno.py +82 -0
  26. devsecpac-2.0.0/src/devsec_cli/scanners/mobsf.py +155 -0
  27. devsecpac-2.0.0/src/devsec_cli/scanners/nmap.py +72 -0
  28. devsecpac-2.0.0/src/devsec_cli/scanners/sbom.py +39 -0
  29. devsecpac-2.0.0/src/devsec_cli/scanners/sca.py +192 -0
  30. devsecpac-2.0.0/src/devsec_cli/scanners/schemathesis.py +77 -0
  31. devsecpac-2.0.0/src/devsec_cli/scanners/secrets.py +170 -0
  32. devsecpac-2.0.0/src/devsec_cli/scanners/semgrep.py +95 -0
  33. devsecpac-2.0.0/src/devsec_cli/scanners/sonar.py +322 -0
  34. devsecpac-2.0.0/src/devsecpac.egg-info/PKG-INFO +249 -0
  35. devsecpac-2.0.0/src/devsecpac.egg-info/SOURCES.txt +38 -0
  36. devsecpac-2.0.0/src/devsecpac.egg-info/dependency_links.txt +1 -0
  37. devsecpac-2.0.0/src/devsecpac.egg-info/entry_points.txt +3 -0
  38. devsecpac-2.0.0/src/devsecpac.egg-info/requires.txt +7 -0
  39. devsecpac-2.0.0/src/devsecpac.egg-info/top_level.txt +1 -0
  40. devsecpac-2.0.0/tests/test_scanners.py +73 -0
@@ -0,0 +1,249 @@
1
+ Metadata-Version: 2.4
2
+ Name: devsecpac
3
+ Version: 2.0.0
4
+ Summary: Universal Autonomous DevSecOps Scanner Orchestrator
5
+ Author-email: Fahad Shaikh <iamfahadshaikh@users.noreply.github.com>
6
+ License: MIT
7
+ Keywords: devsecops,security,sast,dast,sca,sbom,secrets-detection,compliance,kubernetes,container-security
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Topic :: Security
12
+ Classifier: Topic :: Software Development :: Build Tools
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Operating System :: OS Independent
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: rich>=13.0.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: requests>=2.28.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Requires-Dist: pytest-cov; extra == "dev"
27
+
28
+ # devsecpac (Universal Autonomous DevSecOps Orchestrator)
29
+
30
+ DevSecPac is an autonomous multi-engine security scanning orchestrator. It automatically discovers repository structures, executes relevant security tools across SAST, SCA, Secrets, IaC, Containers, Kubernetes, and Mobile stacks, unifies and deduplicates findings, generates local remediation patches, and exports results to CI/CD and ASPM platforms.
31
+
32
+ ---
33
+
34
+ ## Security Engines and Capabilities
35
+
36
+ Below is the complete matrix of integrated engines, their specific security role, the protection gained by running them, and the security risk exposure if skipped:
37
+
38
+ | Security Engine | Security Category | Purpose and Why It Is Included | What Happens If Used | What Happens If Skipped |
39
+ | :--- | :--- | :--- | :--- | :--- |
40
+ | **Gitleaks** | Secret Detection | Scans git commits, branches, and staged files for exposed API keys, private tokens, and passwords using pattern matching. | Catches leaked credentials prior to deployment, preventing account compromise. | High risk of leaking production credentials to public or shared git history. |
41
+ | **TruffleHog** | Deep Secret Scanning | Uses Shannon entropy and comprehensive secret verification algorithms across entire commit histories. | Finds rotated or legacy credentials buried deep in past commit trees. | Hidden, forgotten keys remaining in historical commits remain undetected. |
42
+ | **Semgrep** | Fast SAST & Guardrails | Multi-language static code analysis for Python, JS/TS, Go, Java, Docker, and configs without compilation. | Detects injection flaws (XSS, SQLi), insecure library calls, and logic flaws in seconds. | Application logic bugs and common CVE design patterns enter production code. |
43
+ | **Hadolint** | Dockerfile Linter | AST-based Dockerfile parser enforcing container best practices and non-root execution. | Flags root execution, untagged images, unpinned packages, and insecure curl/wget pipes. | Container images risk privilege escalation, bloated layers, and supply-chain tampering. |
44
+ | **GitHub CodeQL** | Semantic SAST | Compiles source code into relational database models to track deep taint-flow paths. | Flags complex, multi-hop remote code execution and cross-file injection paths. | Inter-procedural taint flow vulnerabilities slip past simple regex linters. |
45
+ | **SonarQube** | SAST & Quality Gate | Enterprise code quality, maintainability, test coverage, and security vulnerability analyzer. | Enforces strict release quality gates and identifies long-term maintainability debt. | Technical debt and security code smells accumulate unchecked across sprints. |
46
+ | **Checkov** | IaC Security | Scans Terraform, CloudFormation, Kubernetes, ARM, and Docker compose manifests against compliance benchmarks. | Catches open AWS S3 buckets, overly permissive IAM roles, and missing encryption. | Cloud infrastructure misconfigurations reach production, causing cloud leaks. |
47
+ | **Kubeconform** | Kubernetes Schema | Validates Kubernetes YAML against official OpenAPI and custom resource definition (CRD) schemas. | Blocks invalid API versions, missing spec fields, and syntax mistakes before deployment. | `kubectl apply` failures or silent cluster deployment rejections during rollouts. |
48
+ | **Kyverno CLI** | K8s Policy as Code | Evaluates Kubernetes manifests against security admission policies (e.g. Pod Security Standards). | Enforces mandatory read-only root filesystems, memory limits, and drops Linux capabilities. | Workloads run with host namespaces or excessive kernel privileges in cluster. |
49
+ | **Aqua Trivy** | Filesystem & Vuln SCA | Deep scanning of OS packages, application lockfiles, and container base layers. | Detects known CVEs in installed dependencies with severity and fixed version metadata. | Vulnerable third-party dependencies are deployed with unpatched vulnerabilities. |
50
+ | **OWASP Dependency-Check** | Software Composition (SCA) | Analyzes project dependencies for known published vulnerabilities against NVD CVE feeds. | Comprehensive enterprise visibility across Java, .NET, Node, and Python packages. | Dependency vulnerabilities in legacy libraries remain hidden without CVE alerts. |
51
+ | **Syft** | SBOM Generation | Inspects project dependencies and packages to build a machine-readable software inventory. | Produces CycloneDX-compliant SBOMs required by federal and compliance mandates. | Zero visibility into software supply chain; non-compliant with standard audits. |
52
+ | **Cosign (Sigstore)** | Supply Chain Attestation | Cryptographically signs generated SBOM artifacts and container images. | Guarantees pipeline tamper-proof provenance and satisfies SLSA level 2/3 requirements. | Inability to prove that build artifacts were not tampered with post-build. |
53
+ | **OWASP ZAP** | Baseline DAST | Dynamic application security testing of running HTTP web endpoints and APIs. | Identifies active runtime issues: missing CSP/HSTS headers, cookie flags, and active XSS. | Runtime misconfigurations and missing transport security go unnoticed in production. |
54
+ | **Schemathesis** | API Contract Security | Property-based fuzzing of OpenAPI, Swagger, and GraphQL interface schemas. | Discovers edge-case unhandled server 500 exceptions, type crashes, and input parsing errors. | API endpoints crash when receiving unexpected or malformed customer requests. |
55
+ | **Nmap** | Port & Service Discovery | Scans network targets and localhost to detect exposed ports and service banners. | Identifies open backend database ports or debug listeners inadvertently exposed. | Database, management, or debug ports remain exposed to external networks. |
56
+ | **MobSF** | Mobile Security (SAST) | Security analysis of Android and iOS application source directories and manifests. | Detects exported activities, insecure storage, and broken permission boundaries. | Mobile client secrets and insecure local storage vulnerabilities reach mobile stores. |
57
+
58
+ ---
59
+
60
+ ## Usage Variations
61
+
62
+ DevSecPac can be consumed in two primary workflows:
63
+ 1. **As a Standalone Python Package** (`pip install devsecpac`)
64
+ 2. **As an Air-Gapped Docker Container** (`docker run iamfahadshaikh/devsec-cli:latest`)
65
+
66
+ ---
67
+
68
+ ### Section 1: Running as a Python Package
69
+
70
+ Install the orchestrator into your Python environment:
71
+
72
+ ```bash
73
+ pip install devsecpac
74
+ ```
75
+
76
+ #### 1. Setup Required Tools Automatically
77
+ DevSecPac includes an autonomous installer that downloads and configures missing binary security engines into your local user path (`~/.local/bin`):
78
+ ```bash
79
+ devsec setup
80
+ ```
81
+
82
+ #### 2. Check Tool Discovery
83
+ Inspect which scanners are active and detected in your environment:
84
+ ```bash
85
+ devsec info
86
+ ```
87
+
88
+ #### 3. Run Autonomous Full Scan
89
+ Scan the current directory or target project path:
90
+ ```bash
91
+ devsec scan .
92
+ ```
93
+
94
+ #### 4. Run Targeted Scanners
95
+ Select specific security engines using comma-separated engine names:
96
+ ```bash
97
+ # Scan secrets and static code
98
+ devsec scan . -t gitleaks,semgrep
99
+
100
+ # Scan container Dockerfile and Kubernetes manifests
101
+ devsec scan . -t hadolint,checkov,kubeconform
102
+ ```
103
+
104
+ #### 5. Scan a Remote Git Repository
105
+ Ingest and scan a remote repository directly:
106
+ ```bash
107
+ devsec scan -r https://github.com/owner/repository.git -t semgrep,hadolint
108
+ ```
109
+
110
+ #### 6. Export to Enterprise ASPM (DefectDojo)
111
+ Push deduplicated vulnerability findings directly into DefectDojo:
112
+ ```bash
113
+ devsec scan . --defectdojo-push \
114
+ --defectdojo-url "http://localhost:8080" \
115
+ --defectdojo-key "your-api-token"
116
+ ```
117
+
118
+ #### 7. Generate Remediation Patch
119
+ Create a unified Git patch containing recommended fixes for local verification:
120
+ ```bash
121
+ devsec fix . --patch-output devsec-fix.patch
122
+
123
+ # Inspect the patch
124
+ git apply --check devsec-fix.patch
125
+
126
+ # Apply after manual review
127
+ git apply devsec-fix.patch
128
+ ```
129
+
130
+ #### 8. Suppress Known Findings (.devsecignore)
131
+ To bypass a specific rule or CVE permanently:
132
+ ```bash
133
+ # Suppress a specific rule on a file
134
+ echo "Dockerfile:DL3008" >> .devsecignore
135
+
136
+ # Suppress a specific CVE
137
+ echo "CVE-2024-XXXX" >> .devsecignore
138
+ ```
139
+
140
+ ---
141
+
142
+ ### Section 2: Running via Docker Image
143
+
144
+ The official Docker image (`iamfahadshaikh/devsec-cli:latest`) packages all 16 security engines, runtimes, and dependencies into a hardened container running as unprivileged user `devsecuser` (UID: 10001).
145
+
146
+ #### 1. Check Tool Status Inside Container
147
+ ```bash
148
+ docker run --rm iamfahadshaikh/devsec-cli:latest info
149
+ ```
150
+
151
+ #### 2. Scan Local Workspace
152
+ Mount your host source directory into `/workspace`:
153
+ ```bash
154
+ docker run --rm \
155
+ -v "$(pwd)":/workspace \
156
+ iamfahadshaikh/devsec-cli:latest scan .
157
+ ```
158
+
159
+ #### 3. Run Fast Scan (Secrets + SAST)
160
+ ```bash
161
+ docker run --rm \
162
+ -v "$(pwd)":/workspace \
163
+ iamfahadshaikh/devsec-cli:latest scan . -t gitleaks,semgrep,hadolint
164
+ ```
165
+
166
+ #### 4. Generate Remediation Patch from Container
167
+ ```bash
168
+ docker run --rm \
169
+ -v "$(pwd)":/workspace \
170
+ iamfahadshaikh/devsec-cli:latest fix . --patch-output devsec-fix.patch
171
+ ```
172
+
173
+ #### 5. Remote Repository Scanning
174
+ Scan any remote repository without cloning it locally:
175
+ ```bash
176
+ docker run --rm \
177
+ iamfahadshaikh/devsec-cli:latest scan -r https://github.com/owner/repository.git -t semgrep,trivy
178
+ ```
179
+
180
+ #### 6. Integration in CI/CD (GitHub Actions)
181
+ ```yaml
182
+ name: DevSecOps Autonomous Scan
183
+
184
+ on: [push, pull_request]
185
+
186
+ jobs:
187
+ security:
188
+ runs-on: ubuntu-latest
189
+ steps:
190
+ - uses: actions/checkout@v4
191
+ - name: Run DevSecPac Security Suite
192
+ run: |
193
+ docker run --rm -v ${{ github.workspace }}:/workspace \
194
+ iamfahadshaikh/devsec-cli:latest scan .
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Publishing to PyPI as a Python Package
200
+
201
+ ### Required Files Checklist for Python Packaging
202
+
203
+ A production-ready Python package requires:
204
+ 1. `pyproject.toml` (Build system, package metadata, dependencies, and CLI entry points).
205
+ 2. `README.md` (Package description, documentation, and installation guide).
206
+ 3. `LICENSE` (Permissive license file, e.g. MIT).
207
+ 4. `src/<package_name>/` (Clean module package structure with `__init__.py`).
208
+ 5. `tests/` (Unit test suite verified with pytest).
209
+
210
+ ### Publishing Procedure
211
+
212
+ #### Step 1: Install Build and Distribution Utilities
213
+ ```bash
214
+ pip install --upgrade build twine
215
+ ```
216
+
217
+ #### Step 2: Build Source Distribution and Wheel
218
+ Run from repository root:
219
+ ```bash
220
+ python -m build
221
+ ```
222
+ This generates the distribution archives inside the `dist/` directory:
223
+ - `dist/devsecpac-2.0.0.tar.gz` (Source Archive)
224
+ - `dist/devsecpac-2.0.0-py3-none-any.whl` (Built Wheel)
225
+
226
+ #### Step 3: Validate Built Packages
227
+ Run `twine check` to ensure your README format, metadata, and syntax pass PyPI requirements:
228
+ ```bash
229
+ twine check dist/*
230
+ ```
231
+
232
+ #### Step 4: Test Upload to TestPyPI (Recommended First Step)
233
+ Verify metadata and package rendering on TestPyPI:
234
+ ```bash
235
+ twine upload --repository testpypi dist/*
236
+ ```
237
+
238
+ #### Step 5: Official Production Upload to PyPI
239
+ Upload the final package to the Python Package Index:
240
+ ```bash
241
+ twine upload dist/*
242
+ ```
243
+ Enter your PyPI API token (`__token__` as username and your token as password) when prompted. Once complete, users can install it globally via `pip install devsecpac`.
244
+
245
+ ---
246
+
247
+ ## License
248
+
249
+ This project is licensed under the MIT License.
@@ -0,0 +1,222 @@
1
+ # devsecpac (Universal Autonomous DevSecOps Orchestrator)
2
+
3
+ DevSecPac is an autonomous multi-engine security scanning orchestrator. It automatically discovers repository structures, executes relevant security tools across SAST, SCA, Secrets, IaC, Containers, Kubernetes, and Mobile stacks, unifies and deduplicates findings, generates local remediation patches, and exports results to CI/CD and ASPM platforms.
4
+
5
+ ---
6
+
7
+ ## Security Engines and Capabilities
8
+
9
+ Below is the complete matrix of integrated engines, their specific security role, the protection gained by running them, and the security risk exposure if skipped:
10
+
11
+ | Security Engine | Security Category | Purpose and Why It Is Included | What Happens If Used | What Happens If Skipped |
12
+ | :--- | :--- | :--- | :--- | :--- |
13
+ | **Gitleaks** | Secret Detection | Scans git commits, branches, and staged files for exposed API keys, private tokens, and passwords using pattern matching. | Catches leaked credentials prior to deployment, preventing account compromise. | High risk of leaking production credentials to public or shared git history. |
14
+ | **TruffleHog** | Deep Secret Scanning | Uses Shannon entropy and comprehensive secret verification algorithms across entire commit histories. | Finds rotated or legacy credentials buried deep in past commit trees. | Hidden, forgotten keys remaining in historical commits remain undetected. |
15
+ | **Semgrep** | Fast SAST & Guardrails | Multi-language static code analysis for Python, JS/TS, Go, Java, Docker, and configs without compilation. | Detects injection flaws (XSS, SQLi), insecure library calls, and logic flaws in seconds. | Application logic bugs and common CVE design patterns enter production code. |
16
+ | **Hadolint** | Dockerfile Linter | AST-based Dockerfile parser enforcing container best practices and non-root execution. | Flags root execution, untagged images, unpinned packages, and insecure curl/wget pipes. | Container images risk privilege escalation, bloated layers, and supply-chain tampering. |
17
+ | **GitHub CodeQL** | Semantic SAST | Compiles source code into relational database models to track deep taint-flow paths. | Flags complex, multi-hop remote code execution and cross-file injection paths. | Inter-procedural taint flow vulnerabilities slip past simple regex linters. |
18
+ | **SonarQube** | SAST & Quality Gate | Enterprise code quality, maintainability, test coverage, and security vulnerability analyzer. | Enforces strict release quality gates and identifies long-term maintainability debt. | Technical debt and security code smells accumulate unchecked across sprints. |
19
+ | **Checkov** | IaC Security | Scans Terraform, CloudFormation, Kubernetes, ARM, and Docker compose manifests against compliance benchmarks. | Catches open AWS S3 buckets, overly permissive IAM roles, and missing encryption. | Cloud infrastructure misconfigurations reach production, causing cloud leaks. |
20
+ | **Kubeconform** | Kubernetes Schema | Validates Kubernetes YAML against official OpenAPI and custom resource definition (CRD) schemas. | Blocks invalid API versions, missing spec fields, and syntax mistakes before deployment. | `kubectl apply` failures or silent cluster deployment rejections during rollouts. |
21
+ | **Kyverno CLI** | K8s Policy as Code | Evaluates Kubernetes manifests against security admission policies (e.g. Pod Security Standards). | Enforces mandatory read-only root filesystems, memory limits, and drops Linux capabilities. | Workloads run with host namespaces or excessive kernel privileges in cluster. |
22
+ | **Aqua Trivy** | Filesystem & Vuln SCA | Deep scanning of OS packages, application lockfiles, and container base layers. | Detects known CVEs in installed dependencies with severity and fixed version metadata. | Vulnerable third-party dependencies are deployed with unpatched vulnerabilities. |
23
+ | **OWASP Dependency-Check** | Software Composition (SCA) | Analyzes project dependencies for known published vulnerabilities against NVD CVE feeds. | Comprehensive enterprise visibility across Java, .NET, Node, and Python packages. | Dependency vulnerabilities in legacy libraries remain hidden without CVE alerts. |
24
+ | **Syft** | SBOM Generation | Inspects project dependencies and packages to build a machine-readable software inventory. | Produces CycloneDX-compliant SBOMs required by federal and compliance mandates. | Zero visibility into software supply chain; non-compliant with standard audits. |
25
+ | **Cosign (Sigstore)** | Supply Chain Attestation | Cryptographically signs generated SBOM artifacts and container images. | Guarantees pipeline tamper-proof provenance and satisfies SLSA level 2/3 requirements. | Inability to prove that build artifacts were not tampered with post-build. |
26
+ | **OWASP ZAP** | Baseline DAST | Dynamic application security testing of running HTTP web endpoints and APIs. | Identifies active runtime issues: missing CSP/HSTS headers, cookie flags, and active XSS. | Runtime misconfigurations and missing transport security go unnoticed in production. |
27
+ | **Schemathesis** | API Contract Security | Property-based fuzzing of OpenAPI, Swagger, and GraphQL interface schemas. | Discovers edge-case unhandled server 500 exceptions, type crashes, and input parsing errors. | API endpoints crash when receiving unexpected or malformed customer requests. |
28
+ | **Nmap** | Port & Service Discovery | Scans network targets and localhost to detect exposed ports and service banners. | Identifies open backend database ports or debug listeners inadvertently exposed. | Database, management, or debug ports remain exposed to external networks. |
29
+ | **MobSF** | Mobile Security (SAST) | Security analysis of Android and iOS application source directories and manifests. | Detects exported activities, insecure storage, and broken permission boundaries. | Mobile client secrets and insecure local storage vulnerabilities reach mobile stores. |
30
+
31
+ ---
32
+
33
+ ## Usage Variations
34
+
35
+ DevSecPac can be consumed in two primary workflows:
36
+ 1. **As a Standalone Python Package** (`pip install devsecpac`)
37
+ 2. **As an Air-Gapped Docker Container** (`docker run iamfahadshaikh/devsec-cli:latest`)
38
+
39
+ ---
40
+
41
+ ### Section 1: Running as a Python Package
42
+
43
+ Install the orchestrator into your Python environment:
44
+
45
+ ```bash
46
+ pip install devsecpac
47
+ ```
48
+
49
+ #### 1. Setup Required Tools Automatically
50
+ DevSecPac includes an autonomous installer that downloads and configures missing binary security engines into your local user path (`~/.local/bin`):
51
+ ```bash
52
+ devsec setup
53
+ ```
54
+
55
+ #### 2. Check Tool Discovery
56
+ Inspect which scanners are active and detected in your environment:
57
+ ```bash
58
+ devsec info
59
+ ```
60
+
61
+ #### 3. Run Autonomous Full Scan
62
+ Scan the current directory or target project path:
63
+ ```bash
64
+ devsec scan .
65
+ ```
66
+
67
+ #### 4. Run Targeted Scanners
68
+ Select specific security engines using comma-separated engine names:
69
+ ```bash
70
+ # Scan secrets and static code
71
+ devsec scan . -t gitleaks,semgrep
72
+
73
+ # Scan container Dockerfile and Kubernetes manifests
74
+ devsec scan . -t hadolint,checkov,kubeconform
75
+ ```
76
+
77
+ #### 5. Scan a Remote Git Repository
78
+ Ingest and scan a remote repository directly:
79
+ ```bash
80
+ devsec scan -r https://github.com/owner/repository.git -t semgrep,hadolint
81
+ ```
82
+
83
+ #### 6. Export to Enterprise ASPM (DefectDojo)
84
+ Push deduplicated vulnerability findings directly into DefectDojo:
85
+ ```bash
86
+ devsec scan . --defectdojo-push \
87
+ --defectdojo-url "http://localhost:8080" \
88
+ --defectdojo-key "your-api-token"
89
+ ```
90
+
91
+ #### 7. Generate Remediation Patch
92
+ Create a unified Git patch containing recommended fixes for local verification:
93
+ ```bash
94
+ devsec fix . --patch-output devsec-fix.patch
95
+
96
+ # Inspect the patch
97
+ git apply --check devsec-fix.patch
98
+
99
+ # Apply after manual review
100
+ git apply devsec-fix.patch
101
+ ```
102
+
103
+ #### 8. Suppress Known Findings (.devsecignore)
104
+ To bypass a specific rule or CVE permanently:
105
+ ```bash
106
+ # Suppress a specific rule on a file
107
+ echo "Dockerfile:DL3008" >> .devsecignore
108
+
109
+ # Suppress a specific CVE
110
+ echo "CVE-2024-XXXX" >> .devsecignore
111
+ ```
112
+
113
+ ---
114
+
115
+ ### Section 2: Running via Docker Image
116
+
117
+ The official Docker image (`iamfahadshaikh/devsec-cli:latest`) packages all 16 security engines, runtimes, and dependencies into a hardened container running as unprivileged user `devsecuser` (UID: 10001).
118
+
119
+ #### 1. Check Tool Status Inside Container
120
+ ```bash
121
+ docker run --rm iamfahadshaikh/devsec-cli:latest info
122
+ ```
123
+
124
+ #### 2. Scan Local Workspace
125
+ Mount your host source directory into `/workspace`:
126
+ ```bash
127
+ docker run --rm \
128
+ -v "$(pwd)":/workspace \
129
+ iamfahadshaikh/devsec-cli:latest scan .
130
+ ```
131
+
132
+ #### 3. Run Fast Scan (Secrets + SAST)
133
+ ```bash
134
+ docker run --rm \
135
+ -v "$(pwd)":/workspace \
136
+ iamfahadshaikh/devsec-cli:latest scan . -t gitleaks,semgrep,hadolint
137
+ ```
138
+
139
+ #### 4. Generate Remediation Patch from Container
140
+ ```bash
141
+ docker run --rm \
142
+ -v "$(pwd)":/workspace \
143
+ iamfahadshaikh/devsec-cli:latest fix . --patch-output devsec-fix.patch
144
+ ```
145
+
146
+ #### 5. Remote Repository Scanning
147
+ Scan any remote repository without cloning it locally:
148
+ ```bash
149
+ docker run --rm \
150
+ iamfahadshaikh/devsec-cli:latest scan -r https://github.com/owner/repository.git -t semgrep,trivy
151
+ ```
152
+
153
+ #### 6. Integration in CI/CD (GitHub Actions)
154
+ ```yaml
155
+ name: DevSecOps Autonomous Scan
156
+
157
+ on: [push, pull_request]
158
+
159
+ jobs:
160
+ security:
161
+ runs-on: ubuntu-latest
162
+ steps:
163
+ - uses: actions/checkout@v4
164
+ - name: Run DevSecPac Security Suite
165
+ run: |
166
+ docker run --rm -v ${{ github.workspace }}:/workspace \
167
+ iamfahadshaikh/devsec-cli:latest scan .
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Publishing to PyPI as a Python Package
173
+
174
+ ### Required Files Checklist for Python Packaging
175
+
176
+ A production-ready Python package requires:
177
+ 1. `pyproject.toml` (Build system, package metadata, dependencies, and CLI entry points).
178
+ 2. `README.md` (Package description, documentation, and installation guide).
179
+ 3. `LICENSE` (Permissive license file, e.g. MIT).
180
+ 4. `src/<package_name>/` (Clean module package structure with `__init__.py`).
181
+ 5. `tests/` (Unit test suite verified with pytest).
182
+
183
+ ### Publishing Procedure
184
+
185
+ #### Step 1: Install Build and Distribution Utilities
186
+ ```bash
187
+ pip install --upgrade build twine
188
+ ```
189
+
190
+ #### Step 2: Build Source Distribution and Wheel
191
+ Run from repository root:
192
+ ```bash
193
+ python -m build
194
+ ```
195
+ This generates the distribution archives inside the `dist/` directory:
196
+ - `dist/devsecpac-2.0.0.tar.gz` (Source Archive)
197
+ - `dist/devsecpac-2.0.0-py3-none-any.whl` (Built Wheel)
198
+
199
+ #### Step 3: Validate Built Packages
200
+ Run `twine check` to ensure your README format, metadata, and syntax pass PyPI requirements:
201
+ ```bash
202
+ twine check dist/*
203
+ ```
204
+
205
+ #### Step 4: Test Upload to TestPyPI (Recommended First Step)
206
+ Verify metadata and package rendering on TestPyPI:
207
+ ```bash
208
+ twine upload --repository testpypi dist/*
209
+ ```
210
+
211
+ #### Step 5: Official Production Upload to PyPI
212
+ Upload the final package to the Python Package Index:
213
+ ```bash
214
+ twine upload dist/*
215
+ ```
216
+ Enter your PyPI API token (`__token__` as username and your token as password) when prompted. Once complete, users can install it globally via `pip install devsecpac`.
217
+
218
+ ---
219
+
220
+ ## License
221
+
222
+ This project is licensed under the MIT License.
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "devsecpac"
7
+ version = "2.0.0"
8
+ description = "Universal Autonomous DevSecOps Scanner Orchestrator"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "Fahad Shaikh", email = "iamfahadshaikh@users.noreply.github.com"}
14
+ ]
15
+ keywords = [
16
+ "devsecops",
17
+ "security",
18
+ "sast",
19
+ "dast",
20
+ "sca",
21
+ "sbom",
22
+ "secrets-detection",
23
+ "compliance",
24
+ "kubernetes",
25
+ "container-security"
26
+ ]
27
+ classifiers = [
28
+ "Development Status :: 4 - Beta",
29
+ "Intended Audience :: Developers",
30
+ "Intended Audience :: Information Technology",
31
+ "Topic :: Security",
32
+ "Topic :: Software Development :: Build Tools",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.9",
35
+ "Programming Language :: Python :: 3.10",
36
+ "Programming Language :: Python :: 3.11",
37
+ "Programming Language :: Python :: 3.12",
38
+ "Operating System :: OS Independent"
39
+ ]
40
+
41
+ dependencies = [
42
+ "rich>=13.0.0",
43
+ "pyyaml>=6.0",
44
+ "requests>=2.28.0"
45
+ ]
46
+
47
+ [project.optional-dependencies]
48
+ dev = [
49
+ "pytest>=7.0.0",
50
+ "pytest-cov"
51
+ ]
52
+
53
+ [project.scripts]
54
+ devsec = "devsec_cli.cli:main"
55
+ devsecpac = "devsec_cli.cli:main"
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ """devsec-cli: Universal Autonomous DevSecOps Scanner Orchestrator."""
2
+
3
+ __version__ = "0.1.0"
4
+ __author__ = "Fahad Shaikh"
@@ -0,0 +1,98 @@
1
+ """Finding bypass and suppression mechanism (.devsecignore)."""
2
+
3
+ from pathlib import Path
4
+ from typing import List, Set, Tuple
5
+ from .contracts import FindingDetail, ToolResult, FindingCounts, StatusEnum
6
+
7
+
8
+ class FindingBypassManager:
9
+ """Loads and checks rule or file-level bypass definitions from .devsecignore or .devsec-suppress."""
10
+
11
+ def __init__(self, target_dir: Path):
12
+ self.target_dir = target_dir
13
+ self.ignore_rules: Set[str] = set()
14
+ self.ignore_file_rules: Set[Tuple[str, str]] = set() # (normalized_path, rule_id)
15
+ self.ignore_cves: Set[str] = set()
16
+ self._load_ignore_file()
17
+
18
+ def _load_ignore_file(self):
19
+ """Looks for .devsecignore or .devsec-suppress in repository root."""
20
+ possible_files = [
21
+ self.target_dir / ".devsecignore",
22
+ self.target_dir / ".devsec-suppress"
23
+ ]
24
+
25
+ for pf in possible_files:
26
+ if pf.is_file():
27
+ try:
28
+ for line in pf.read_text(encoding="utf-8").splitlines():
29
+ line = line.strip()
30
+ if not line or line.startswith("#"):
31
+ continue
32
+
33
+ # Format 1: file:rule (e.g. Dockerfile:DL3008 or requirements.txt:CVE-2024-1234)
34
+ if ":" in line:
35
+ parts = line.split(":", 1)
36
+ fpath_norm = parts[0].strip().replace("\\", "/").lower()
37
+ rule_norm = parts[1].strip().upper()
38
+ self.ignore_file_rules.add((fpath_norm, rule_norm))
39
+ # Format 2: standalone rule/CVE (e.g. DL3008, CK_DOCKER_3, CVE-2024-21626)
40
+ elif line.upper().startswith("CVE-") or line.upper().startswith("GHSA-"):
41
+ self.ignore_cves.add(line.upper())
42
+ else:
43
+ self.ignore_rules.add(line.upper())
44
+ except Exception:
45
+ pass
46
+
47
+ def is_bypassed(self, finding: FindingDetail) -> bool:
48
+ """Determines if a finding is suppressed by a specific bypass rule."""
49
+ if not self.ignore_rules and not self.ignore_file_rules and not self.ignore_cves:
50
+ return False
51
+
52
+ norm_file = finding.file.strip().replace("\\", "/").lower()
53
+ rule_upper = (finding.rule or "").strip().upper()
54
+
55
+ # Check global rule match
56
+ if rule_upper in self.ignore_rules:
57
+ return True
58
+
59
+ # Check file + rule match
60
+ for fpath, r in self.ignore_file_rules:
61
+ if (fpath in norm_file or norm_file.endswith(fpath)) and r == rule_upper:
62
+ return True
63
+
64
+ # Check CVE match
65
+ if rule_upper in self.ignore_cves:
66
+ return True
67
+
68
+ return False
69
+
70
+ def filter_tool_results(self, results: List[ToolResult]) -> Tuple[List[ToolResult], int]:
71
+ """Filters out bypassed findings from each ToolResult and recalculates finding counts."""
72
+ bypassed_count = 0
73
+
74
+ for r in results:
75
+ if not r.items:
76
+ continue
77
+
78
+ active_items = []
79
+ for item in r.items:
80
+ if self.is_bypassed(item):
81
+ bypassed_count += 1
82
+ else:
83
+ active_items.append(item)
84
+
85
+ r.items = active_items
86
+
87
+ # Recount findings for this tool
88
+ r.findings.critical = sum(1 for i in active_items if i.severity.upper() == "CRITICAL")
89
+ r.findings.high = sum(1 for i in active_items if i.severity.upper() == "HIGH")
90
+ r.findings.medium = sum(1 for i in active_items if i.severity.upper() == "MEDIUM")
91
+ r.findings.low = sum(1 for i in active_items if i.severity.upper() == "LOW")
92
+ r.findings.info = sum(1 for i in active_items if i.severity.upper() == "INFO")
93
+
94
+ # Adjust status if quality gate failed purely due to suppressed items
95
+ if r.status == StatusEnum.FAIL and not r.findings.has_blocking:
96
+ r.status = StatusEnum.PASS
97
+
98
+ return results, bypassed_count