|
| 1 | +# Vulnerability Report |
| 2 | + |
| 3 | +Pulp Python provides vulnerability scanning capabilities to help you identify known security |
| 4 | +vulnerabilities in your Python packages. This feature integrates with the [Open Source Vulnerabilities (OSV)](https://osv.dev/) |
| 5 | +database to scan Pulp `RepositoryVersions` for vulnerable packages. |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +Before generating the vulnerability report, ensure that: |
| 10 | + |
| 11 | +1. You have a Python repository with [synced or uploaded content](site:pulp_python/docs/user/guides/sync/) |
| 12 | +2. Pulp has connectivity to the [OSV API](https://api.osv.dev/v1/query) |
| 13 | + |
| 14 | +## Generating a vulnerability report |
| 15 | + |
| 16 | +To scan a `RepositoryVersion` for vulnerabilities, you need to pass the name of the repository and |
| 17 | +optionally the version: |
| 18 | + |
| 19 | +```bash |
| 20 | +pulp vulnerability-report create --repository my-repo --version 1 |
| 21 | +``` |
| 22 | + |
| 23 | +## Understanding Scan Results |
| 24 | + |
| 25 | +After a scan completes, vulnerability information is available in two places: |
| 26 | + |
| 27 | +### 1. Repository Version Level |
| 28 | + |
| 29 | +The `RepositoryVersion` includes a `vuln_report` field that references a vulnerability report |
| 30 | +containing all vulnerabilities found in that version: |
| 31 | + |
| 32 | +```bash |
| 33 | +pulp python repository version show --repository my-repo |
| 34 | +``` |
| 35 | + |
| 36 | +The response includes: |
| 37 | + |
| 38 | +```json |
| 39 | +{ |
| 40 | + "pulp_href": "/pulp/api/v3/repositories/python/python/.../versions/1/", |
| 41 | + "number": 1, |
| 42 | + ... |
| 43 | + "vuln_report": "/pulp/api/v3/vuln-reports/..." |
| 44 | +} |
| 45 | +``` |
| 46 | + |
| 47 | +### 2. Content Level |
| 48 | + |
| 49 | +Individual Python package content units also include vulnerability report references: |
| 50 | + |
| 51 | +```bash |
| 52 | +pulp python content list |
| 53 | +``` |
| 54 | + |
| 55 | +Each package in the response includes: |
| 56 | + |
| 57 | +```json |
| 58 | +{ |
| 59 | + "pulp_href": "/pulp/api/v3/content/python/packages/.../", |
| 60 | + "name": "Django", |
| 61 | + ... |
| 62 | + "vuln_report": "/pulp/api/v3/vuln-reports/...", |
| 63 | + ... |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +### Viewing Vulnerability Details |
| 68 | + |
| 69 | +To view the actual vulnerability data, retrieve the vulnerability report: |
| 70 | + |
| 71 | +```bash |
| 72 | +# Get vulnerability report details |
| 73 | +pulp vulnerability-report show --href ${VULN_REPORT_HREF} |
| 74 | +``` |
| 75 | + |
| 76 | +The report contains detailed information about each vulnerability, including: |
| 77 | + |
| 78 | +- **CVE identifiers**: Common Vulnerabilities and Exposures identifiers |
| 79 | +- **Affected versions**: Which package versions are vulnerable |
| 80 | +- **Fixed versions**: Which versions contain fixes |
| 81 | +- **References**: Links to advisories and patches |
| 82 | +- **Repository and Content**: Pulp `RepositoryVersion` and `Content` impacted |
| 83 | + |
| 84 | +## Example Workflow |
| 85 | + |
| 86 | +Here's a complete example of scanning a repository for vulnerabilities: |
| 87 | + |
| 88 | +```bash |
| 89 | +# 1. Create a repository |
| 90 | +pulp python repository create --name security-scan-repo |
| 91 | + |
| 92 | +# 2. Create a remote pointing to PyPI |
| 93 | +pulp python remote create \ |
| 94 | + --name pypi-remote \ |
| 95 | + --url https://pypi.org/ \ |
| 96 | + --includes '["django==5.2.1"]' |
| 97 | + |
| 98 | +# 3. Sync the repository |
| 99 | +pulp python repository sync \ |
| 100 | + --name security-scan-repo \ |
| 101 | + --remote pypi-remote |
| 102 | + |
| 103 | +# 4. Scan for vulnerabilities |
| 104 | +pulp vulnerability-report create --repository security-scan-repo |
| 105 | + |
| 106 | +# 5. View the vulnerability report |
| 107 | +VULN_REPORT=$(pulp python repository version show --repository security-scan-repo | jq -r '.vuln_report') |
| 108 | +pulp vulnerability-report show --href $VULN_REPORT |
| 109 | +``` |
0 commit comments