-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Assign some tags based on method naming conventions Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> * Python Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com> --------- Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
- Loading branch information
Showing
8 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
platform/frontends/x2cpg/src/main/scala/io/appthreat/x2cpg/passes/taggers/EasyTagsPass.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.appthreat.x2cpg.passes.taggers | ||
|
||
import io.circe.* | ||
import io.circe.parser.* | ||
import io.shiftleft.codepropertygraph.Cpg | ||
import io.shiftleft.codepropertygraph.generated.Languages | ||
import io.shiftleft.codepropertygraph.generated.nodes.Method | ||
import io.shiftleft.passes.CpgPass | ||
import io.shiftleft.semanticcpg.language.* | ||
|
||
import java.util.regex.Pattern | ||
|
||
/** Creates tags on any node | ||
*/ | ||
class EasyTagsPass(atom: Cpg) extends CpgPass(atom): | ||
|
||
val language: String = atom.metaData.language.head | ||
|
||
override def run(dstGraph: DiffGraphBuilder): Unit = | ||
atom.method.internal.name(".*(valid|check).*").newTagNode("validation").store()(dstGraph) | ||
atom.method.internal.name("is[A-Z].*").newTagNode("validation").store()(dstGraph) | ||
if language == Languages.PYTHON || language == Languages.PYTHONSRC then | ||
atom.method.internal.name("is_[a-z].*").newTagNode("validation").store()(dstGraph) | ||
atom.method.internal.name(".*(encode|escape|sanit).*").newTagNode("sanitization").store()( | ||
dstGraph | ||
) | ||
atom.method.internal.name(".*(login|authenti).*").newTagNode("authentication").store()( | ||
dstGraph | ||
) | ||
atom.method.internal.name(".*(authori).*").newTagNode("authorization").store()(dstGraph) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters