Skip to content

Commit bfdd180

Browse files
ckunkiArBridgeman
andauthored
Feature/402 nox session report resolved security issues (#770)
* #402: Created nox task to detect resolved GitHub security issues * added typehint to get_vulnerabilities_from_latest_tag * Validated warning in test and hid warning from pytest output * Renamed method resolved to resolved_vulnerabilities * Renamed nox task and class SecurityAudit once again * Added integration test * merged changes from changelog.py * Removed comment * Removed unused imports * nox -s format:fix * Upload metrics.json only once and only for the main branch * Modified trigger * Updated GitHub workflows * nox -s format:fix * Fixed unit tests * Updated workflows once again * fixed typo in event name * Apply suggestions from code review Co-authored-by: Ariel Schulz <43442541+ArBridgeman@users.noreply.github.com> * Added comment for CLI option --disable-pip to pip-audit * Update .github/workflows/ci.yml Co-authored-by: Ariel Schulz <43442541+ArBridgeman@users.noreply.github.com> * Fixed test naming and implementation --------- Co-authored-by: Ariel Schulz <43442541+ArBridgeman@users.noreply.github.com>
1 parent 98543bb commit bfdd180

File tree

19 files changed

+258
-94
lines changed

19 files changed

+258
-94
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/merge-gate.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Merge-Gate
22

33
on:
44
workflow_call:
5+
inputs:
6+
root-event:
7+
description: GitHub event triggering the root workflow ci.yml
8+
required: false
9+
type: string
10+
default: unknown
511

612
jobs:
713
run-fast-checks:
@@ -15,12 +21,15 @@ jobs:
1521
needs:
1622
- run-fast-checks
1723
uses: ./.github/workflows/report.yml
24+
with:
25+
upload-metrics: false
1826
secrets: inherit
1927
permissions:
2028
contents: read
2129

2230
approve-run-slow-tests:
2331
name: Approve Running Slow Tests?
32+
if: ${{ inputs.root-event != 'schedule' }}
2433
runs-on: "ubuntu-24.04"
2534
permissions:
2635
contents: read

.github/workflows/pr-merge.yml

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/report.yml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/changes/changes_0.15.0.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@
2424

2525
## 🔩 Internal
2626

27-
* Update depdency constraints
28-
* Relock dependencies
27+
* Update dependency constraints
28+
* Relock dependencies

doc/changes/unreleased.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ The `report.yml` is also called after the `checks.yml` completes. This allows us
1111
to get linting, security, and unit test coverage before running the `slow-checks.yml`,
1212
as described in the [Pull Request description](https://exasol.github.io/python-toolbox/main/user_guide/features/github_workflows/index.html#pull-request).
1313

14+
This release also adds a `vulnerabilities:resolved` Nox session, which reports GitHub security issues resolved since the last release.
15+
1416
This release fixes a vulnerability by updating the `poetry.lock` file.
1517

1618
| Name | Version | ID | Fix Versions | Updated to |
@@ -19,6 +21,10 @@ This release fixes a vulnerability by updating the `poetry.lock` file.
1921

2022
To ensure usage of secure packages, it is up to the user to similarly relock their dependencies.
2123

24+
## Features
25+
26+
* #402: Created nox session `vulnerabilities:resolved` to report resolved GitHub security issues
27+
2228
## Refactoring
2329

2430
* #764: Updated `action/upload-pages-artifact` from v4 to [v5](https://github.com/actions/upload-pages-artifact/releases/tag/v5.0.0)
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
Managing dependencies
2-
=====================
1+
Managing Dependencies and Vulnerabilities
2+
=========================================
33

4-
+--------------------------+------------------+----------------------------------------+
5-
| Nox session | CI Usage | Action |
6-
+==========================+==================+========================================+
7-
| ``dependency:licenses`` | ``report.yml`` | Uses ``pip-licenses`` to return |
8-
| | | packages with their licenses |
9-
+--------------------------+------------------+----------------------------------------+
10-
| ``dependency:audit`` | No | Uses ``pip-audit`` to return active |
11-
| | | vulnerabilities in our dependencies |
12-
+--------------------------+------------------+----------------------------------------+
4+
+------------------------------+----------------+-------------------------------------+
5+
| Nox session | CI Usage | Action |
6+
+==============================+================+=====================================+
7+
| ``dependency:licenses`` | ``report.yml`` | Uses ``pip-licenses`` to return |
8+
| | | packages with their licenses |
9+
+------------------------------+----------------+-------------------------------------+
10+
| ``dependency:audit`` | No | Uses ``pip-audit`` to report active |
11+
| | | vulnerabilities in our dependencies |
12+
+------------------------------+----------------+-------------------------------------+
13+
| ``vulnerabilities:resolved`` | No | Uses ``pip-audit`` to report known |
14+
| | | vulnerabilities in dependencies |
15+
| | | that have been resolved in |
16+
| | | comparison to the last release. |
17+
+------------------------------+----------------+-------------------------------------+

exasol/toolbox/nox/_dependencies.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,21 @@
99
from exasol.toolbox.util.dependencies.audit import (
1010
PipAuditException,
1111
Vulnerabilities,
12+
get_vulnerabilities,
13+
get_vulnerabilities_from_latest_tag,
1214
)
1315
from exasol.toolbox.util.dependencies.licenses import (
1416
PackageLicenseReport,
1517
get_licenses,
1618
)
1719
from exasol.toolbox.util.dependencies.poetry_dependencies import get_dependencies
20+
from exasol.toolbox.util.dependencies.track_vulnerabilities import DependenciesAudit
21+
from noxconfig import PROJECT_CONFIG
1822

1923

2024
@nox.session(name="dependency:licenses", python=False)
2125
def dependency_licenses(session: Session) -> None:
22-
"""Return the packages with their licenses"""
26+
"""Report licenses for all dependencies."""
2327
dependencies = get_dependencies(working_directory=Path())
2428
licenses = get_licenses()
2529
license_markdown = PackageLicenseReport(
@@ -30,7 +34,7 @@ def dependency_licenses(session: Session) -> None:
3034

3135
@nox.session(name="dependency:audit", python=False)
3236
def audit(session: Session) -> None:
33-
"""Check for known vulnerabilities"""
37+
"""Report known vulnerabilities."""
3438

3539
try:
3640
vulnerabilities = Vulnerabilities.load_from_pip_audit(working_directory=Path())
@@ -39,3 +43,14 @@ def audit(session: Session) -> None:
3943

4044
security_issue_dict = vulnerabilities.security_issue_dict
4145
print(json.dumps(security_issue_dict, indent=2))
46+
47+
48+
@nox.session(name="vulnerabilities:resolved", python=False)
49+
def report_resolved_vulnerabilities(session: Session) -> None:
50+
"""Report resolved vulnerabilities in dependencies."""
51+
path = PROJECT_CONFIG.root_path
52+
audit = DependenciesAudit(
53+
previous_vulnerabilities=get_vulnerabilities_from_latest_tag(path),
54+
current_vulnerabilities=get_vulnerabilities(path),
55+
)
56+
print(audit.report_resolved_vulnerabilities())

exasol/toolbox/templates/github/workflows/cd.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
build-and-publish:
1717
needs:
18-
- check-release-tag
18+
- check-release-tag
1919
name: Build & Publish
2020
uses: ./.github/workflows/build-and-publish.yml
2121
permissions:
@@ -25,7 +25,7 @@ jobs:
2525

2626
publish-docs:
2727
needs:
28-
- build-and-publish
28+
- build-and-publish
2929
name: Publish Documentation
3030
uses: ./.github/workflows/gh-pages.yml
3131
permissions:

exasol/toolbox/templates/github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,21 @@ jobs:
1111
merge-gate:
1212
name: Merge Gate
1313
uses: ./.github/workflows/merge-gate.yml
14+
with:
15+
root-event: ${{ github.event_name }}
1416
secrets: inherit
1517
permissions:
1618
contents: read
1719

1820
report:
21+
# Job merge-gate requires manual approval for running the slow checks. If
22+
# current workflow ci.yml is triggered by schedule, there is no manual
23+
# interaction, manual approval will never be given, slow checks will not
24+
# be executed, merge-gate will never terminate, and the report will never
25+
# be called.
1926
name: Report
2027
needs:
21-
- merge-gate
28+
- merge-gate
2229
uses: ./.github/workflows/report.yml
2330
secrets: inherit
2431
permissions:

0 commit comments

Comments
 (0)