Skip to content

Commit 177bf37

Browse files
authored
Security/477 switch sonar token to env (#478)
* Switch `sonar:check` to use `SONAR_TOKEN` from the environment * Remove non-ASCII Unicodes in issue / PR templates * Relock dependencies to resolve vulnerabilities for urllib3 * As env variable not guaranteed, type hint needed to be updated
1 parent 5791a0e commit 177bf37

File tree

11 files changed

+49
-40
lines changed

11 files changed

+49
-40
lines changed

.github/ISSUE_TEMPLATE/blank.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: 📝 Blank Issue
2+
name: Blank Issue
33
about: Blank Issue
4-
title: 📝 <Insert Title>
4+
title: <Insert Title>
55
labels:
66
assignees: ''
77

.github/ISSUE_TEMPLATE/documentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: 📚 Documentation
2+
name: Documentation
33
about: Add/Improve Documentation
4-
title: 📚 <Insert Title>
4+
title: <Insert Title>
55
labels: documentation
66
assignees: ''
77

.github/ISSUE_TEMPLATE/feature.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: Feature
2+
name: Feature
33
about: Add/Implement Feature
4-
title: <Insert Title>
4+
title: <Insert Title>
55
labels: feature
66
assignees: ''
77

.github/ISSUE_TEMPLATE/refactoring.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: 🔧 Refactoring
2+
name: Refactoring
33
about: Refactor
4-
title: 🔧 <Insert Title>
4+
title: <Insert Title>
55
labels: refactoring
66
assignees: ''
77

.github/ISSUE_TEMPLATE/security.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
2-
name: 🔐 Security Issue
2+
name: Security Issue
33
about: Fix Security Issue
4-
title: 🔐 <Insert Title>
4+
title: <Insert Title>
55
labels: security
66
assignees: ''
77

.github/PULL_REQUEST_TEMPLATE/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Checklist
1+
# Checklist
22

33
* [ ] Have you updated the changelog?
44
* [ ] Have you updated the cookiecutter-template?

.github/workflows/report.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ jobs:
3636
run: poetry run -- nox -s project:report -- --format json | tee metrics.json
3737

3838
- name: Upload to sonar
39-
run: poetry run -- nox -s sonar:check -- ${{ secrets.SONAR_TOKEN }}
39+
env:
40+
SONAR_TOKEN: "${{ secrets.SONAR_TOKEN }}"
41+
run: poetry run -- nox -s sonar:check
4042

4143
- name: Upload Artifacts
4244
uses: actions/upload-artifact@v4.6.2

doc/changes/unreleased.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
# Unreleased
2+
3+
## Security
4+
* #477: Switched `sonar:check` to use `SONAR_TOKEN` from the environment

exasol/toolbox/nox/_artifacts.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import json
2+
import os
23
import re
34
import shutil
45
import sqlite3
56
import sys
67
from collections.abc import Iterable
78
from pathlib import Path
9+
from typing import Optional
810

911
import nox
1012
from nox import Session
@@ -186,7 +188,9 @@ def _prepare_coverage_xml(session: Session, source: Path) -> None:
186188
session.run(*command)
187189

188190

189-
def _upload_to_sonar(session: Session, sonar_token: str, config: Config) -> None:
191+
def _upload_to_sonar(
192+
session: Session, sonar_token: Optional[str], config: Config
193+
) -> None:
190194
command = [
191195
"pysonar",
192196
"--sonar-token",
@@ -208,6 +212,6 @@ def _upload_to_sonar(session: Session, sonar_token: str, config: Config) -> None
208212
@nox.session(name="sonar:check", python=False)
209213
def upload_artifacts_to_sonar(session: Session) -> None:
210214
"""Upload artifacts to sonar for analysis"""
211-
sonar_token = session.posargs[0]
215+
sonar_token = os.getenv("SONAR_TOKEN")
212216
_prepare_coverage_xml(session, PROJECT_CONFIG.source)
213217
_upload_to_sonar(session, sonar_token, PROJECT_CONFIG)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ jobs:
3333
run: poetry run -- nox -s artifacts:validate
3434

3535
- name: Upload to sonar
36-
run: poetry run -- nox -s sonar:check -- ${{ secrets.SONAR_TOKEN }}
36+
env:
37+
SONAR_TOKEN: "${{ secrets.SONAR_TOKEN }}"
38+
run: poetry run -- nox -s sonar:check
3739

3840
- name: Generate Report
3941
run: poetry run -- nox -s project:report -- --format json | tee metrics.json

0 commit comments

Comments
 (0)