-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix check on negated alternatives #372
Conversation
Since they are negated predicates and connected with an logical or, the alternative pred should be satisfied as long as not all predicates are ensured.
It's a wrong fix I did there, should be more like:
|
This also needed a more concrete assertion with signatur "errorCount(int expectedCount)"
Here a little update:
The assertion code
does not throw any errors, which is weird in my eyes. So I started debugging and it turns out, that the error is catched by an if statement at this line: CryptoAnalysis/CryptoAnalysis/src/main/java/crypto/predicates/PredicateHandler.java Line 233 in 35d0916
Is there a reason why it should throw now errors if a predicate is missed but could be ensured by the rule? I'm still convinced that this is an issue, but it may need a larger test with at least two rules to get over this if statement.. |
scheduled for 2.8 |
A fix and tests have been added in #376. Therefore, this PR is not required anymore |
How does the check work?
CrySL required preds will be stored as
CrySLConstraint
s. TheConstraintSolvers
will convert requiredCrySLConstraint
s toAlternativeReqPredicates
, see hereCryptoAnalysis/CryptoAnalysis/src/main/java/crypto/constraints/ConstraintSolver.java
Line 111 in 35d0916
All required preds, also the
AlternativeReqPredicate
s, will be used to check wether aAnalysisSeedWithSpecification
satisfies its required predicates or not in thecheckPredicates()
method.CryptoAnalysis/CryptoAnalysis/src/main/java/crypto/analysis/AnalysisSeedWithSpecification.java
Line 377 in 35d0916
What is the issue?
Checking on an
AlternativeReqPredicate
with all alternative predicates negated - keep in mind that they are connected with a logical or - is done by returning false (false = predicates does not satisfy constraints) if only one negated alternative predicate is ensured by the seed.That is wrong, because it should actually satisfy its constraints, if at least one negated alternative predicate is not ensured, since they are connected with a logical or.
This needs to be testet first
Current tests does not cover this code, so someone should write tests before merging.