security-use 0.1.1__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.
- security_use/__init__.py +15 -0
- security_use/cli.py +348 -0
- security_use/dependency_scanner.py +199 -0
- security_use/fixers/__init__.py +6 -0
- security_use/fixers/dependency_fixer.py +196 -0
- security_use/fixers/iac_fixer.py +191 -0
- security_use/iac/__init__.py +9 -0
- security_use/iac/base.py +69 -0
- security_use/iac/cloudformation.py +207 -0
- security_use/iac/rules/__init__.py +29 -0
- security_use/iac/rules/aws.py +338 -0
- security_use/iac/rules/base.py +96 -0
- security_use/iac/rules/registry.py +115 -0
- security_use/iac/terraform.py +177 -0
- security_use/iac_scanner.py +215 -0
- security_use/models.py +139 -0
- security_use/osv_client.py +386 -0
- security_use/parsers/__init__.py +16 -0
- security_use/parsers/base.py +43 -0
- security_use/parsers/pipfile.py +133 -0
- security_use/parsers/poetry_lock.py +42 -0
- security_use/parsers/pyproject.py +178 -0
- security_use/parsers/requirements.py +86 -0
- security_use/py.typed +0 -0
- security_use/reporter.py +368 -0
- security_use/scanner.py +74 -0
- security_use-0.1.1.dist-info/METADATA +92 -0
- security_use-0.1.1.dist-info/RECORD +30 -0
- security_use-0.1.1.dist-info/WHEEL +4 -0
- security_use-0.1.1.dist-info/entry_points.txt +2 -0
security_use/scanner.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"""Main scanner interface for security_use."""
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Optional
|
|
5
|
+
|
|
6
|
+
from security_use.models import ScanResult
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def scan_dependencies(
|
|
10
|
+
path: Optional[str] = None,
|
|
11
|
+
file_content: Optional[str] = None,
|
|
12
|
+
file_type: Optional[str] = None,
|
|
13
|
+
) -> ScanResult:
|
|
14
|
+
"""Scan dependencies for known vulnerabilities.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
path: Path to scan (file or directory). Defaults to current directory.
|
|
18
|
+
file_content: Direct content to scan (alternative to path).
|
|
19
|
+
file_type: Type of dependency file when using file_content.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
ScanResult containing any vulnerabilities found.
|
|
23
|
+
"""
|
|
24
|
+
from security_use.dependency_scanner import DependencyScanner
|
|
25
|
+
|
|
26
|
+
scanner = DependencyScanner()
|
|
27
|
+
|
|
28
|
+
if file_content is not None:
|
|
29
|
+
return scanner.scan_content(file_content, file_type or "requirements.txt")
|
|
30
|
+
|
|
31
|
+
scan_path = Path(path) if path else Path.cwd()
|
|
32
|
+
return scanner.scan_path(scan_path)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def scan_iac(
|
|
36
|
+
path: Optional[str] = None,
|
|
37
|
+
file_content: Optional[str] = None,
|
|
38
|
+
file_type: Optional[str] = None,
|
|
39
|
+
) -> ScanResult:
|
|
40
|
+
"""Scan Infrastructure as Code for security misconfigurations.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
path: Path to scan (file or directory). Defaults to current directory.
|
|
44
|
+
file_content: Direct content to scan (alternative to path).
|
|
45
|
+
file_type: Type of IaC file when using file_content.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
ScanResult containing any IaC findings.
|
|
49
|
+
"""
|
|
50
|
+
from security_use.iac_scanner import IaCScanner
|
|
51
|
+
|
|
52
|
+
scanner = IaCScanner()
|
|
53
|
+
|
|
54
|
+
if file_content is not None:
|
|
55
|
+
return scanner.scan_content(file_content, file_type or "terraform")
|
|
56
|
+
|
|
57
|
+
scan_path = Path(path) if path else Path.cwd()
|
|
58
|
+
return scanner.scan_path(scan_path)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def get_vulnerability_fix(vulnerability_id: str, package: str) -> Optional[str]:
|
|
62
|
+
"""Get the recommended fix version for a vulnerability.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
vulnerability_id: The CVE or vulnerability ID.
|
|
66
|
+
package: The package name.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Recommended version to upgrade to, or None if unknown.
|
|
70
|
+
"""
|
|
71
|
+
from security_use.osv_client import OSVClient
|
|
72
|
+
|
|
73
|
+
client = OSVClient()
|
|
74
|
+
return client.get_fix_version(vulnerability_id, package)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: security-use
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: Security scanning tool for dependencies and Infrastructure as Code
|
|
5
|
+
Project-URL: Homepage, https://github.com/security-use/security-use
|
|
6
|
+
Project-URL: Repository, https://github.com/security-use/security-use
|
|
7
|
+
Project-URL: Issues, https://github.com/security-use/security-use/issues
|
|
8
|
+
Author-email: Security Use <security@example.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: cloudformation,dependencies,iac,scanner,security,terraform,vulnerability
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Security
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: click>=8.0.0
|
|
24
|
+
Requires-Dist: httpx>=0.25.0
|
|
25
|
+
Requires-Dist: packaging>=23.0
|
|
26
|
+
Requires-Dist: python-hcl2>=4.3.0
|
|
27
|
+
Requires-Dist: pyyaml>=6.0
|
|
28
|
+
Requires-Dist: rich>=13.0.0
|
|
29
|
+
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
|
|
30
|
+
Provides-Extra: dev
|
|
31
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
32
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
34
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
35
|
+
Requires-Dist: types-pyyaml>=6.0.0; extra == 'dev'
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# security-use
|
|
39
|
+
|
|
40
|
+
A security scanning library for Python projects. Provides vulnerability scanning for dependencies and Infrastructure as Code (IaC) files.
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **Dependency Scanning**: Detect known vulnerabilities (CVEs) in Python packages
|
|
45
|
+
- **IaC Scanning**: Find security misconfigurations in Terraform, CloudFormation, and other IaC formats
|
|
46
|
+
- **Automated Fixes**: Generate and apply fixes for detected issues
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install security-use
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Usage
|
|
55
|
+
|
|
56
|
+
### Command Line
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Scan dependencies
|
|
60
|
+
security-use scan deps /path/to/project
|
|
61
|
+
|
|
62
|
+
# Scan IaC files
|
|
63
|
+
security-use scan iac /path/to/terraform
|
|
64
|
+
|
|
65
|
+
# Scan everything
|
|
66
|
+
security-use scan all /path/to/project
|
|
67
|
+
|
|
68
|
+
# Auto-fix vulnerable dependencies
|
|
69
|
+
security-use fix /path/to/project
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Python API
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from security_use import scan_dependencies, scan_iac
|
|
76
|
+
|
|
77
|
+
# Scan dependencies
|
|
78
|
+
result = scan_dependencies("/path/to/project")
|
|
79
|
+
|
|
80
|
+
for vuln in result.vulnerabilities:
|
|
81
|
+
print(f"{vuln.package}: {vuln.severity.value}")
|
|
82
|
+
|
|
83
|
+
# Scan IaC
|
|
84
|
+
result = scan_iac("/path/to/terraform")
|
|
85
|
+
|
|
86
|
+
for finding in result.iac_findings:
|
|
87
|
+
print(f"{finding.rule_id}: {finding.title}")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
security_use/__init__.py,sha256=Gtd1i9N9-ryLly2_BgS8zhlXdpibWZ_bBKmNbUuNwxU,376
|
|
2
|
+
security_use/cli.py,sha256=8kniz6b4FQaUZfFTP0Wvf1X3tcTqa9hXH-ALBrdx8Mo,10329
|
|
3
|
+
security_use/dependency_scanner.py,sha256=dCBeM3oESywlQK2idfC1eQG-s9SaY2WkLvrFL8VXgwk,5678
|
|
4
|
+
security_use/iac_scanner.py,sha256=ObnVJU74nSS9OoAZmhJOA79_FcvlzIgxOcuWAMkSliA,6714
|
|
5
|
+
security_use/models.py,sha256=0vvcV-Cyn_0-Itn0c-apsWz3GBGqN1BMPZeP_MxlXb8,4092
|
|
6
|
+
security_use/osv_client.py,sha256=yKJVTbKU3fP0QM69KMYWA2xTDOAfKmEQOn5BLhQ8lY8,13380
|
|
7
|
+
security_use/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
security_use/reporter.py,sha256=hBdJ0mEKwWVqc7gxx3WuaM2ryiu25_nQndNoo0Iga1I,12613
|
|
9
|
+
security_use/scanner.py,sha256=bclsLKPUNPPD6vLN2pBycw_gUkvA74QiOERnut2uK5w,2209
|
|
10
|
+
security_use/fixers/__init__.py,sha256=pBcjyXWiRznnrLyWr2-eXs_4eaAh9L9UJyqGigM1X8c,206
|
|
11
|
+
security_use/fixers/dependency_fixer.py,sha256=zDJadR3ExQ_vqaRgVMZSWqskLRjlf14dk3usNmwTqsM,6415
|
|
12
|
+
security_use/fixers/iac_fixer.py,sha256=f7VKXkkvhBsq90E04QoG7V277Ljj48qORJc3Yoqy3lk,6514
|
|
13
|
+
security_use/iac/__init__.py,sha256=MmabfNA36rJvtWgOUWaq5VJf2TPNWXyhMmVuI8qVHV4,238
|
|
14
|
+
security_use/iac/base.py,sha256=8lrOIwlRbDJYIzb4Epfn1OA91UUjhXHxo61ACwFkhmE,1810
|
|
15
|
+
security_use/iac/cloudformation.py,sha256=6E1fE6xFW4uMlFmuD2cEiubUaOzMlqdcpwWsMfAzJ_c,8197
|
|
16
|
+
security_use/iac/terraform.py,sha256=-0PY-Dw5qpKKn28BliwNv8yRkGp5eGKACwrZVaQ9u80,6191
|
|
17
|
+
security_use/iac/rules/__init__.py,sha256=RfFXACozqDYqV4EYgmRxsvk6rERZP_0qN1L9gZlG5TE,711
|
|
18
|
+
security_use/iac/rules/aws.py,sha256=9KjHv5v3ppanuFOJ-p-_qv-CiehxHBAuwFSF_IL5qOM,12152
|
|
19
|
+
security_use/iac/rules/base.py,sha256=C-LgpwIUIBAyoPwL-tC_ioF6opbmSk-nRWB_vfM22ec,2567
|
|
20
|
+
security_use/iac/rules/registry.py,sha256=s8SNKR3FRY44kwo8Uh3Gcu8t-c1GQB6Cg3bkuO_b8DE,3055
|
|
21
|
+
security_use/parsers/__init__.py,sha256=zYVpwqZOH1M0n8WCLPkb5uhcjr-ID4TSQa32BKLuplI,491
|
|
22
|
+
security_use/parsers/base.py,sha256=hA0w9GIlIAsYifsNuKOlh1thh5u08PBo92afoU2PnFk,1119
|
|
23
|
+
security_use/parsers/pipfile.py,sha256=1cginV92IWvaT4A19ScaLUBy4y3fS5mEXtFpurxFPLI,3800
|
|
24
|
+
security_use/parsers/poetry_lock.py,sha256=OipaEBr03Kkfgt5bTFXCswbiAFcVXEzcz-e-N5jeGWk,1167
|
|
25
|
+
security_use/parsers/pyproject.py,sha256=Tjmb-EZnp22RPsIgFiznSwMXrktLb-_CpT5o7RbXcWc,5407
|
|
26
|
+
security_use/parsers/requirements.py,sha256=slenW0vs1Hd5J7ZOI1YAd9Ha3qV1Fzt_PZ7gErzhha8,2687
|
|
27
|
+
security_use-0.1.1.dist-info/METADATA,sha256=OtpUH2Kb7ZkWJM9UojP5wZlq4QWusfNnfDZiePytpuE,2727
|
|
28
|
+
security_use-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
29
|
+
security_use-0.1.1.dist-info/entry_points.txt,sha256=PSZqVVwt2h3HFeoFQCCoscMsJD6C5r3HQGzqcBYCRMM,55
|
|
30
|
+
security_use-0.1.1.dist-info/RECORD,,
|