Commit ef53138 1 parent 6d19cd0 commit ef53138 Copy full SHA for ef53138
File tree 1 file changed +27
-1
lines changed
platform/frontends/x2cpg/src/main/scala/io/appthreat/x2cpg/passes/taggers
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -120,16 +120,42 @@ class ChennaiTagsPass(atom: Cpg) extends CpgPass(atom):
120
120
}
121
121
end tagPhpRoutes
122
122
private def tagRubyRoutes (dstGraph : DiffGraphBuilder ): Unit =
123
+ // rails
124
+ val railsRoutePrefix = " .*(get|post|put|delete|head|option|resources|namespace)\\ s('|\" ).*"
123
125
atom.method.where(
124
126
_.filename(" config/routes.rb" ).code(
125
- " .*(get|post|put|delete|head|option|resources|namespace).* "
127
+ railsRoutePrefix
126
128
)
127
129
).newTagNode(
128
130
FRAMEWORK_ROUTE
129
131
).store()(dstGraph)
132
+ atom.method.where(
133
+ _.filename(" config/routes.rb" ).code(
134
+ railsRoutePrefix
135
+ )
136
+ ).parameter.newTagNode(FRAMEWORK_INPUT ).store()(
137
+ dstGraph
138
+ )
130
139
atom.method.filename(" .*controller.rb.*" ).parameter.newTagNode(FRAMEWORK_INPUT ).store()(
131
140
dstGraph
132
141
)
142
+ atom.method.filename(" .*controller.rb.*" ).methodReturn.newTagNode(
143
+ FRAMEWORK_OUTPUT
144
+ ).store()(dstGraph)
145
+ // sinatra
146
+ val sinatraRoutePrefix =
147
+ " (app\\ .namespace|app\\ .)?(get|post|delete|head|options|put)\\ s('|\" ).*"
148
+ atom.method.code(sinatraRoutePrefix).newTagNode(
149
+ FRAMEWORK_ROUTE
150
+ ).store()(dstGraph)
151
+ atom.method.code(sinatraRoutePrefix).parameter
152
+ .newTagNode(FRAMEWORK_INPUT ).store()(
153
+ dstGraph
154
+ )
155
+ atom.method.code(sinatraRoutePrefix).methodReturn.newTagNode(
156
+ FRAMEWORK_OUTPUT
157
+ ).store()(dstGraph)
158
+ end tagRubyRoutes
133
159
override def run (dstGraph : DiffGraphBuilder ): Unit =
134
160
if language == Languages .PYTHON || language == Languages .PYTHONSRC then
135
161
tagPythonRoutes(dstGraph)
You can’t perform that action at this time.
0 commit comments