Skip to content
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

GoSrc2Cpg : AST generation for switch case #3018

Merged
merged 5 commits into from
Jul 12, 2023

Conversation

khemrajrathore
Copy link
Contributor

The PR covers the following

  • Ast creation for switch case
  • Corresponding Ast and dataflow tests
  • Moved JumpTargetNode from kotlin2cpg to x2cpg as it was redundant
  • Ignored 1 test case in Ast creation where due to the presence of a local node in the condition of switch it throws an error
  • Ignored 1 test case in Dataflow where due to an empty condition in the switch, dataflow doesn't propagate

README.md Outdated
@@ -1,5 +1,5 @@
Joern - The Bug Hunter's Workbench
===
===
Copy link
Contributor

Choose a reason for hiding this comment

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

What's this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

random Js test case was failing, so this space was to retrigger checks

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be removed, it pollutes the diff

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, removing this

@@ -100,7 +107,7 @@ trait AstForStatementsCreator { this: AstCreator =>
private def astForConditionExpression(condStmt: ParserNodeInfo): Ast = {
condStmt.node match {
case ParenExpr => astForNode(condStmt.json(ParserKeys.X)).head
case _ => Ast()
case _ => astsForStatement(condStmt).head
Copy link
Contributor

Choose a reason for hiding this comment

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

Please guarantee that astForStatement(condStmt) is always non-empty to avoid NoSuchElementException here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, will take that precaution

README.md Outdated
@@ -1,5 +1,5 @@
Joern - The Bug Hunter's Workbench
===
===
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this should be removed, it pollutes the diff

@@ -100,7 +107,7 @@ trait AstForStatementsCreator { this: AstCreator =>
private def astForConditionExpression(condStmt: ParserNodeInfo): Ast = {
condStmt.node match {
case ParenExpr => astForNode(condStmt.json(ParserKeys.X)).head
case _ => Ast()
case _ => astsForStatement(condStmt).head
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
case _ => astsForStatement(condStmt).head
case _ => astsForStatement(condStmt).headOption.getOrElse(Ast())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DavidBakerEffendi Have made the suggested changes

@pandurangpatil
Copy link
Contributor

@khemrajrathore take the latest updates from the master and lets get this merged

@khemrajrathore
Copy link
Contributor Author

@DavidBakerEffendi Can we get this merged?

@DavidBakerEffendi DavidBakerEffendi merged commit 3188ac0 into joernio:master Jul 12, 2023
5 checks passed
@khemrajrathore khemrajrathore deleted the khemraj/switchcase branch July 12, 2023 13:34
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.

4 participants