[semanticcpg] feat: add validation level#5894
Conversation
| 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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:
- I think we can make the API change already in this PR, so remove
throwOnError - Rename
validationLeveltofatalValidationLeveland add a comment stating that all checks with a level lower or equal will result in an exception.
There was a problem hiding this comment.
Regarding 1, I'll remove throwOnError then for usages which has throwOnError = false, I'll set fatalValidationLevel to 0. Sounds good?
There was a problem hiding this comment.
Sounds good. That will result in the old behavior.
7fe9a19 to
6a8475f
Compare
e0331a2 to
ccb755b
Compare
Added a validation level for the
PostFrontendValidatorchecks. 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
PostFrontendValidatorusages updated accordinglyRelates to https://github.com/ShiftLeftSecurity/codescience/issues/8762