Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(script): Verify checker labelling invariants (e.g., guideline:XX:rule, profile:defaultprofile:sensitiveprofile:extreme) with the label-tool #4275

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

whisperity
Copy link
Contributor

@whisperity whisperity commented Jun 24, 2024

Important

⛔ Blocked by #4274.

There were multiple occasions in which the labelling of the checkers was lacking some serious invariants which we all implicitly agreed upon, but never actually and thoroughly verified with tooling. Violating these invariants should have never resulted in serious issues, but quirky or unexpected behaviour could have occurred.

This patch extends the label-tool with facilities to verify, and, optionally, support automatically fixing the label set of each checker "globally" to uphold the following invariants:

  • profile:default profile:sensitive profile:extreme
  • guideline:sei-cert sei-cert:<some rule's ID>
  • guideline:sei-cert profile:security
  • clangsa (alpha.* debug.*) ⇒ ¬( profile:(default|sensitive|extreme|security|portability) )

@whisperity whisperity added enhancement 🌟 tools 🛠️ Meta-tag for all the additional tools supplied with CodeChecker: plist2html, tu_collector, etc. config ⚙️ labels Jun 24, 2024
@whisperity whisperity added this to the release 6.25.0 milestone Jun 24, 2024
@whisperity whisperity added the label-tool 🔖 Related to tooling that manages the analyzer/checker label configuration label Jun 25, 2024
@whisperity whisperity changed the title feat(script): Verify checker labelling invariants (e.g., guideline:XX:rule, defaultsensitiveextreme) with the label-tool feat(script): Verify checker labelling invariants (e.g., guideline:XX:rule, profile:defaultprofile:sensitiveprofile:extreme) with the label-tool Jul 2, 2024
Automatically generate the `doc_url` labels for checkers for analysers
which we know how to do this.
(Currently implemented only for Clang SA and Clang-Tidy.)
This tooling does a single HTTP request to download a "Table of
Contents" (ToC) document and uses HTML DOM scraping to extract the list
of checkers and their corresponding documentation link.

There was existing prior work for this feature, but those scripts were
about 3 years old (introduced in 2021. Nov, commit
aa72dc0), and they ceased to properly
work.
For example, for _Clang-Tidy_, the contents of the ToC changed in a
way that the previously used XPath expression did not match anything
at all.
In addition, the previous work at `doc_url.py` (later renamed
`doc_url_generate.py`) only generated labels for the checkers that were
_already_ present in the configuration file, defeating the purpose of
using a script to determine new labels for checkers.

This version reintroduces an improved DOM scraping logic, and enables
generating `doc_url` for checkers that are not yet present in the
configuration file, all the while using the new `label_tool/` package
structure introduced in a previous commit.
Automatically generate the `severity` labels for checkers of analysers
which we know how to.
(Currently implemented only for the Clang diagnostic (warning) flags
exposed through Clang-Tidy.)

There was existing prior work for this feature, but that script was
about 3 years old (introduced in 2021. Nov, commit
8d1a7fe), and due to changes in the
DOM of Sphinx documents, ceased to work properly since.

This refactoring is smaller in scope than the `doc_url` generation that
was done in a previous commit, as the original `compiler_warnings.py`
script accurately generated severities (and `doc_url`s, for that matter)
for previously "unknown" "checkers" as well.
Considering that all previously developed label-generating tools are now
subsumed into the new `label_tool` package, the extra directory is unnecessary.
@whisperity
Copy link
Contributor Author

Added a rule to tear out alpha. checkers from the normal profiles. We shall be able to catch things like #4284 automatically in the future.

@whisperity whisperity force-pushed the feat/script/label-tool/invariant-verification branch from 7210e00 to 414cee2 Compare July 9, 2024 17:33
@whisperity whisperity added the RDY-OnHold 🛑 Patch reviewed and ready, but don't merge due to having to merge a dependent patch first. label Jul 9, 2024
@whisperity whisperity marked this pull request as ready for review July 9, 2024 17:48
After upgrade on `master` to `pylint==3.2.4`, new warnings are enabled
which were not honoured in `label-tool`.
In some cases it might be deemed necessary that a label (e.g., a higher
or lower `severity`) is more appropriate than what the tool would
otherwise auto-generate.
In such cases, a `label-tool-skip:LABEL_KEY` (e.g.,
`label-tool-skip:severity`, as applied in
commit 04d27ab) can indicate to stamp
the fact that a developer overruled the tools' decisions.

Prior to this commit, the tooling actually disregarded this information,
but now I added the necessary handling to the existing aspects.
There were multiple occasions in the past at which point it was realised
that the checker-labelling in the configuration files did not conform to
some "invariants" which we all, or mostly, agreed upon to upkeep, but
only did so ad-hoc and implicitly, without any tooling-based
verification.

N.B., violation of these invariants did not result in **serious** issues
or bugs, but often caused weird and quirky behaviour which was
non-trivial to understand for users.

This patch extends the `label-tool` with facilities to verify and, if
meaningful for the specific rule, automatically fix the label set of
individual checkers as one entity (as opposed to the `doc_url_generate`
or `severity_generate` tools, which only considered the value of a
unique single label), upholding invariants **between** labels, e.g.,
`profile:` labels.

This patch contains 4 implemented rules:

 - `profile:default` ⊆ `profile:sensitive` ⊆ `profile:extreme`
 - `guideline:sei-cert` ⇔ `sei-cert:<rule-number>`
 - `guideline:sei-cert` ⇒ `profile:security`
 - clangsa (alpha.* ∪ debug.*) ⇒
   ¬( `profile:(default|sensitive|extreme|security|portability)` )
@whisperity whisperity force-pushed the feat/script/label-tool/invariant-verification branch from 414cee2 to 3a46b58 Compare July 10, 2024 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config ⚙️ enhancement 🌟 label-tool 🔖 Related to tooling that manages the analyzer/checker label configuration RDY-OnHold 🛑 Patch reviewed and ready, but don't merge due to having to merge a dependent patch first. tools 🛠️ Meta-tag for all the additional tools supplied with CodeChecker: plist2html, tu_collector, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant