Skip to content

[semanticcpg] feat: add validation level#5894

Merged
TNSelahle merged 7 commits intomasterfrom
tebogo/post-processing-validator
Mar 26, 2026
Merged

[semanticcpg] feat: add validation level#5894
TNSelahle merged 7 commits intomasterfrom
tebogo/post-processing-validator

Conversation

@TNSelahle
Copy link
Copy Markdown
Member

@TNSelahle TNSelahle commented Mar 23, 2026

Added a validation level for the PostFrontendValidator checks. Users can specify a validation level to ensure that only failures up to that level throw exceptions.

Once this PR is merged, a new Joern version will be published and CS will be updated to the new version, with PostFrontendValidator usages updated accordingly

Relates to https://github.com/ShiftLeftSecurity/codescience/issues/8762

@TNSelahle TNSelahle requested a review from ml86 March 23, 2026 08:50
case FULLNAME_UNIQUE_METHOD, FULLNAME_UNIQUE_TYPE, FULLNAME_UNIQUE_TYPEDECL, MULTI_REF, BAD_REF_TYPE, NONLOCAL_REF,
MULTI_AST_IN, MULTI_ARG_IN, DUPLICATE_ORDER
/** Newly added checks should have an `addedInLevel` 1 level higher than the highest */
enum ValidationName(val addedInLevel: Int) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid the coupling between validation names which seem to be a sort of category and addedInLevel because with this solution we cannot easily add a new e.g. references check and have it in another level.

Lets just remove the validation name and have each error type have its own level. If we add some point want error type categories, that is an orthogonal thing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. I'll make the changes

* faster checking code, then enable in sptests and prod.
*/
class PostFrontendValidator(cpg: Cpg, throwOnError: Boolean) extends AbstractValidator(cpg) {
class PostFrontendValidator(cpg: Cpg, throwOnError: Boolean = true, validationLevel: Int = Int.MaxValue)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You stated in the PR comment that you want to remove throwOnError later which only leaves validationLevel. I think that is the correct approach with two adjustments:

  1. I think we can make the API change already in this PR, so remove throwOnError
  2. Rename validationLevel to fatalValidationLevel and add a comment stating that all checks with a level lower or equal will result in an exception.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding 1, I'll remove throwOnError then for usages which has throwOnError = false, I'll set fatalValidationLevel to 0. Sounds good?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. That will result in the old behavior.

@TNSelahle TNSelahle force-pushed the tebogo/post-processing-validator branch from 7fe9a19 to 6a8475f Compare March 24, 2026 08:14
@TNSelahle TNSelahle marked this pull request as ready for review March 24, 2026 12:51
@TNSelahle TNSelahle force-pushed the tebogo/post-processing-validator branch from e0331a2 to ccb755b Compare March 25, 2026 14:44
@TNSelahle TNSelahle merged commit a01cdd0 into master Mar 26, 2026
8 checks passed
@TNSelahle TNSelahle deleted the tebogo/post-processing-validator branch March 26, 2026 11:04
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