183 @type ast.Constant |
183 @type ast.Constant |
184 """ |
184 """ |
185 if isinstance(node.value, str): |
185 if isinstance(node.value, str): |
186 self.__context["str"] = node.value |
186 self.__context["str"] = node.value |
187 if not isinstance(node._securityParent, ast.Expr): # docstring |
187 if not isinstance(node._securityParent, ast.Expr): # docstring |
188 self.__context["linerange"] = SecurityUtils.linerange_fix( |
188 self.__context["linerange"] = SecurityUtils.linerange( |
189 node._securityParent |
189 node._securityParent |
190 ) |
190 ) |
191 self.__runChecks("Str") |
191 self.__runChecks("Str") |
192 elif isinstance(node.value, bytes): |
192 elif isinstance(node.value, bytes): |
193 self.__context["bytes"] = node.value |
193 self.__context["bytes"] = node.value |
194 if not isinstance(node._securityParent, ast.Expr): # docstring |
194 if not isinstance(node._securityParent, ast.Expr): # docstring |
195 self.__context["linerange"] = SecurityUtils.linerange_fix( |
195 self.__context["linerange"] = SecurityUtils.linerange( |
196 node._securityParent |
196 node._securityParent |
197 ) |
197 ) |
198 self.__runChecks("Bytes") |
198 self.__runChecks("Bytes") |
199 |
199 |
200 def __preVisit(self, node): |
200 def __preVisit(self, node): |
211 self.__context["import_aliases"] = self.import_aliases |
211 self.__context["import_aliases"] = self.import_aliases |
212 |
212 |
213 if hasattr(node, "lineno"): |
213 if hasattr(node, "lineno"): |
214 self.__context["lineno"] = node.lineno |
214 self.__context["lineno"] = node.lineno |
215 |
215 |
|
216 if hasattr(node, "col_offset"): |
|
217 self.__context["col_offset"] = node.col_offset |
|
218 if hasattr(node, "end_col_offset"): |
|
219 self.__context["end_col_offset"] = node.end_col_offset |
|
220 |
216 self.__context["node"] = node |
221 self.__context["node"] = node |
217 self.__context["linerange"] = SecurityUtils.linerange_fix(node) |
222 self.__context["linerange"] = SecurityUtils.linerange(node) |
218 self.__context["filename"] = self.filename |
223 self.__context["filename"] = self.filename |
219 |
224 |
220 self.seen += 1 |
225 self.seen += 1 |
221 self.depth += 1 |
226 self.depth += 1 |
222 |
227 |