-
Notifications
You must be signed in to change notification settings - Fork 3
Analyzer Draft #111
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
base: main
Are you sure you want to change the base?
Analyzer Draft #111
Conversation
Deleted support for union, intersection and difference. These are operations usdo to create a set of assets, meaning that they could never appear in a reaches, unless in an expr. Therefore, this check_to_step should only take care of the case collect, where it will return the asset pointed by the lhs (where the set operation can be) and checks if the rhs is indeed a step for the specified asset. Deleted support for subType. This is used to denote a subclass, so in the context of an attack step can only be used inside a collect, where the lhs is the subType and the rhs is the associated step. Added comments.
Previously, checking for field and variable was done in the same place. To keep the code manageable and similar to its Java counterpart, this was split into separate functions. Added logging message in case the user mentioned an existing variable but forgot to call it. Added comments.
Previously, variable was not considered a case in _check_to_asset, but it should be. Added comments.
This concludes the verification of all subfunctions as well.
Added verification to ensure repeated defines does not happen. Added comments.
Instead of verifying if an error was found and then setting the class error as True, set it as soon as an error is found. Added comments.
Deleted a raise instruction which wasn't raising anything. Added comments.
The previous implementation, when given a step, would verify if this step was defined by another asset. However, according to the Java check, we should verify the step hierarchy, i.e. if a step is properly extended from the assets parents. For this, when analysing a single step we only check if it is already defined in the asset. In the post analysis, we verify if the steps are properly inherited. Added comments.
Isn't there a check in the java analyzer? I think in MAL it does not make sense to allow the same labels to be used twice, either in associations, assets or let-variables.
Probably yes, we want to support this. Circular dependencies may be possible to capture and report to the user as error.
Isn't there a check in the java analyzer? In this case, I think yes, as that would make possible to extend a whole language (that has its own version and id).
What do you mean here? I think the analyzer should keep track of assets, etc across all files (starting from main.mal) so that it can properly check things. Also, check my changes on the visitor class, moving it to
Don't care about detectors for the time being.
@andrewbwm Do you have any input here?
I think yes, and we should merge. @andrewbwm
Probably not, there are lots of custom metas that we don't want to break. |
|
@tagyieh Resolve the conflicts too. |
Also changed test verification. If a test fails, it is not relevant to know what components of the language are stored in the analyzer; we should only verify that to guarantee that the analyzer correctly processes everything in case of success.
Since we allow for multiple metadata (not only user, modeler and developer), it does not make sense to have specific tests for them.
Tests in operation and in transitive are temporarily altered to ensure all tests pass.
This funciton shall log the error and raise the exception.
Analyzer Draft
This PR is a work in progress to implement an analyzer for the existing MAL compiler, described in this issue. It is a continuation of the previous analyzer draft, which can be found here.
Implementation
malVisitorinmal_visitor.pywill use an analyzermalAnalyzerInterface. Thevisitmethod is overridden inmalVisitorin order to call the checker-methods in themalAnalyzerInterface(if defined).Analyzer Implementation
Language Constituents
MAL Symbols
Notes/Possible checks