CogniCrypt icon indicating copy to clipboard operation
CogniCrypt copied to clipboard

Fix for issue #457

Open marvinvo opened this issue 3 years ago • 0 comments

Description

The built-in methods (alg, mode, padding, and so on) do not work in the REQUIRES section. For example, in the Cipher rule, we have generatedkey[key, alg(transformation)], but the alg does not function and it is interpreted as generatedkey[key, transformation].

Fix

The previous parsing code was actually a dublicate of the getPredicate() method, but it had no check for the “consPred” field, in which ‘alg(’, ‘mode(’ and ‘pad(’ is defined. Hence I just reuse the correctly working getPredicate() method at this place.

More background: As you can also see in the crysl gramma, "pred" field in non-terminal "PredLit"("innerPred.getPred()" in Java code) is defined as a normal predicate and hence it can be simply interpreted like any other predicate too. https://github.com/CROSSINGTUD/CryptSL/blob/25dc97eebdfd30989c312d28dc79a50fb4cc1209/de.darmstadt.tu.crossing.CrySL/src/de/darmstadt/tu/crossing/CrySL.xtext#L245

Fixes #457

Type of change

  • [x] Bug fix (non-breaking change which fixes an issue)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [x] by @shahrzadav with several crysl files

Test Configuration:

  • Eclipse Version:
  • Java Version:
  • OS:

Checklist:

  • [x] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] My changes generate no new warnings
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes

marvinvo avatar Jan 22 '22 09:01 marvinvo