Skip to content

Fix the red SonarCloud gate on main - #96

Merged
insatomcat merged 5 commits into
mainfrom
sonar-new-code-baseline
Aug 7, 2026
Merged

Fix the red SonarCloud gate on main#96
insatomcat merged 5 commits into
mainfrom
sonar-new-code-baseline

Conversation

@insatomcat

@insatomcat insatomcat commented Aug 6, 2026

Copy link
Copy Markdown
Member

Publishing coverage in #94 turned the main gate red. Nothing regressed: new_coverage was simply an ignored condition as long as no report existed.

The project's New Code definition is "previous version", and every analysis in the history ran without one. With no version event to compare against, the period falls back to the first analysis ever, dated 2024-07-31: new_lines 3562 for ncloc 3334, so the entire code base counts as new code. Hence new_coverage 21.1 against a threshold of 80, and new_security_rating C from findings dating back to 2021. Pull requests were never affected, their gate is computed on their own diff.

The first commit is the fix, the others clear the security findings that are worth clearing:

  • ci: pass the version from pyproject.toml to the scanner, so each release gives the period a real boundary.
  • api: the Flask debug entry point listened on 0.0.0.0 while the application authenticates nobody, publishing /start and /stop in clear text around the nginx that carries the TLS, the basic auth and the ACL. It is not the production path, gunicorn imports wsgi:app. Fixes python:S8392, the only blocker.
  • cqfd: pin sphinx-argparse and install it from wheels only, as the workflow steps already are. Fixes docker:S8544 and docker:S8541.
  • cqfd: drop the sonar-scanner 4.7.0 aimed at http://j1.sfl.team:9000/, which this repository no longer reports to since the analysis moved to the workflow. Takes openjdk-8, unzip and wget out of the image, and fixes docker:S6506 and docker:S5332.
  • tests: cover the REST API, 0% to 94%. Without it the single line changed above, in a module at 0%, failed this pull request's own gate: 1 new line to cover, 0 covered.

Six of the ten security findings clear. The remaining four, pythonsecurity:S8701 and S8707 on paths built from argparse arguments, need real input validation rather than a one-line fix and are left out.

The New Code definition is "previous version" and no analysis ever ran
with one, so the period falls back to the first analysis ever: 3562 new
lines for 3334 lines of code, the whole code base. That is what turned
the main gate red on new_coverage and new_security_rating as soon as #94
published coverage. Pull requests were never affected, their gate is
computed on their own diff.

Pass the version from pyproject.toml, which stays the single source of
truth, so each release gives the period a real boundary.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
The application authenticates nobody. In production the vmmgrapi role of
seapath/ansible serves it with gunicorn behind an nginx that carries the
TLS, the basic auth and the ACL, and main() is not that path: gunicorn
imports wsgi:app.

On 0.0.0.0 this debug entry point published every route, /start and
/stop included, in clear text on every interface. Fixes python:S8392.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
A version so a rebuild cannot pick up a new release on its own, and
--only-binary :all: so no dependency runs a setup script at install
time, as commit 9217d68 did for the workflow steps. Fixes docker:S8544
and docker:S8541.

0.6.0 is what the unpinned line already resolved to on the python3.10 of
ubuntu 22.04, so the image does not change.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
The sonar flavor aimed sonar-scanner 4.7.0 at http://j1.sfl.team:9000/,
an SFL instance this repository no longer reports to: commit 1dd9bdf
moved the analysis to SonarCloud, run from the workflow.

Removing it also takes openjdk-8-jre-headless, unzip and wget out of the
image, which nothing else uses, and fixes docker:S6506, the download
following redirects unchecked, and docker:S5332, the clear-text URL.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
vm_manager_api.py was at 0%, so the single line the previous commit
changed failed this pull request's own gate: 1 new line to cover, 0
covered.

Cover the four routes, both branches of execfunc and main(), with every
vm_manager call replaced. The module reaches 94%, the rest being the
__main__ guard. The main() test asserts the bind address.

Signed-off-by: Florent Carli <florent.carli@rte-france.com>
@insatomcat
insatomcat force-pushed the sonar-new-code-baseline branch from 6415501 to 34c63d1 Compare August 6, 2026 10:57
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@insatomcat
insatomcat merged commit ded7abf into main Aug 7, 2026
5 checks passed
@insatomcat
insatomcat deleted the sonar-new-code-baseline branch August 7, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants