cobraphp 0.1.0.dev6__py3-none-any.whl → 0.1.0.dev8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cobraphp/analysis/_call_builder.py +2 -2
- cobraphp/analysis/_callee_index.py +2 -2
- cobraphp/analysis/_declarations.py +1 -1
- cobraphp/analysis/_defuse_builder.py +3 -3
- cobraphp/analysis/_parsing.py +5 -3
- cobraphp/analysis/frameworks.toml +8 -0
- {cobraphp-0.1.0.dev6.dist-info → cobraphp-0.1.0.dev8.dist-info}/METADATA +4 -4
- {cobraphp-0.1.0.dev6.dist-info → cobraphp-0.1.0.dev8.dist-info}/RECORD +11 -11
- {cobraphp-0.1.0.dev6.dist-info → cobraphp-0.1.0.dev8.dist-info}/WHEEL +0 -0
- {cobraphp-0.1.0.dev6.dist-info → cobraphp-0.1.0.dev8.dist-info}/licenses/LICENSE +0 -0
- {cobraphp-0.1.0.dev6.dist-info → cobraphp-0.1.0.dev8.dist-info}/top_level.txt +0 -0
|
@@ -80,10 +80,10 @@ class CallBuilder:
|
|
|
80
80
|
|
|
81
81
|
if callable_node.node_type in NAMED_CALLABLE_TYPES:
|
|
82
82
|
if len(identifier_children) >= 2:
|
|
83
|
-
return str(identifier_children[1].
|
|
83
|
+
return str(identifier_children[1].properties.get("name", ""))
|
|
84
84
|
elif callable_node.node_type in (CLOSURE_TYPE, ARROW_FUNCTION_TYPE):
|
|
85
85
|
if len(identifier_children) >= 1:
|
|
86
|
-
return str(identifier_children[0].
|
|
86
|
+
return str(identifier_children[0].properties.get("name", ""))
|
|
87
87
|
return ""
|
|
88
88
|
|
|
89
89
|
def _build_call_sites(self, call_graph: CallGraph, callee_index: CalleeIndex) -> None:
|
|
@@ -85,7 +85,7 @@ class CalleeIndex:
|
|
|
85
85
|
# Class a method call's receiver (its first child) statically denotes, or None.
|
|
86
86
|
def _receiver_class_name(self, call_site: Node) -> str | None:
|
|
87
87
|
receiver = next(iter(self._ast.succ(call_site)))
|
|
88
|
-
name = str(receiver.
|
|
88
|
+
name = str(receiver.properties.get("name", ""))
|
|
89
89
|
if receiver.node_type == _VARIABLE_TYPE:
|
|
90
90
|
return _enclosing_class_name(self._ast, call_site) if name == _THIS_VARIABLE else None
|
|
91
91
|
if receiver.node_type not in _NAME_TYPES or name.lower() == "parent":
|
|
@@ -108,7 +108,7 @@ def _child_name(ast: AST, node: Node, child_types: frozenset[str]) -> str | None
|
|
|
108
108
|
child = next((c for c in ast.succ(node) if c.node_type in child_types), None)
|
|
109
109
|
if child is None:
|
|
110
110
|
return None
|
|
111
|
-
name = child.
|
|
111
|
+
name = child.properties.get("name", "")
|
|
112
112
|
return str(name) if name else None
|
|
113
113
|
|
|
114
114
|
|
|
@@ -21,7 +21,7 @@ def callable_name(ast: AST, node: Node) -> str:
|
|
|
21
21
|
identifier = next((child for child in ast.succ(node) if child.node_type == "Identifier"), None)
|
|
22
22
|
if identifier is None:
|
|
23
23
|
raise StaticAnalysisError(f"Callable node {node.id} missing Identifier child for name")
|
|
24
|
-
name = identifier.
|
|
24
|
+
name = identifier.properties.get("name", "")
|
|
25
25
|
if not name:
|
|
26
26
|
raise StaticAnalysisError(f"Callable {node.id} Identifier missing 'name' property")
|
|
27
27
|
return str(name)
|
|
@@ -75,7 +75,7 @@ def _extract_param_defs(ast: AST, func_node: Node) -> dict[str, str]:
|
|
|
75
75
|
for param_child in ast.succ(child):
|
|
76
76
|
if param_child.node_type != "Expr_Variable":
|
|
77
77
|
continue
|
|
78
|
-
var_name = param_child.
|
|
78
|
+
var_name = param_child.properties.get("name", "")
|
|
79
79
|
if var_name:
|
|
80
80
|
param_defs[cast(str, var_name)] = param_child.id
|
|
81
81
|
return param_defs
|
|
@@ -185,7 +185,7 @@ def _assignment_target(ast: AST, node: Node) -> tuple[str, Node, Node] | None:
|
|
|
185
185
|
if parts is None or parts[0].node_type != "Expr_Variable":
|
|
186
186
|
return None
|
|
187
187
|
lhs, rhs = parts
|
|
188
|
-
var_name = cast(str, lhs.
|
|
188
|
+
var_name = cast(str, lhs.properties.get("name", ""))
|
|
189
189
|
if not var_name:
|
|
190
190
|
return None
|
|
191
191
|
return var_name, lhs, rhs
|
|
@@ -237,7 +237,7 @@ def _use_scan_children(
|
|
|
237
237
|
return _closure_use_children(ast, node)
|
|
238
238
|
|
|
239
239
|
if node.node_type == "Expr_Variable" and node.id not in lhs_ids:
|
|
240
|
-
var_name = node.
|
|
240
|
+
var_name = node.properties.get("name", "")
|
|
241
241
|
# Skip superglobals — they are sources, not def-use targets
|
|
242
242
|
if var_name and not str(var_name).startswith("_"):
|
|
243
243
|
result.append((node.id, cast(str, var_name)))
|
cobraphp/analysis/_parsing.py
CHANGED
|
@@ -6,8 +6,7 @@ import re
|
|
|
6
6
|
from collections.abc import Callable
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
-
from php_parser_py import AST, PHPVersion, RunnerError
|
|
10
|
-
from php_parser_py import parse_project as _parse_project
|
|
9
|
+
from php_parser_py import AST, Parser, PHPVersion, RunnerError
|
|
11
10
|
|
|
12
11
|
from ._errors import StaticAnalysisError
|
|
13
12
|
|
|
@@ -31,7 +30,10 @@ def parse_project(
|
|
|
31
30
|
if not isinstance(project_path, (str, Path)) or (file_filter is not None and not callable(file_filter)):
|
|
32
31
|
raise StaticAnalysisError("Invalid project path or file filter")
|
|
33
32
|
try:
|
|
34
|
-
|
|
33
|
+
parser = Parser(target_php=version)
|
|
34
|
+
if file_filter is None:
|
|
35
|
+
return parser.parse_project(str(project_path))
|
|
36
|
+
return parser.parse_project(str(project_path), file_filter=file_filter)
|
|
35
37
|
except (OSError, ValueError, TypeError, RuntimeError, RunnerError) as exc:
|
|
36
38
|
raise StaticAnalysisError(f"Failed to parse project: {exc}") from exc
|
|
37
39
|
|
|
@@ -36,3 +36,11 @@ name = "thinkphp"
|
|
|
36
36
|
marker = "thinkphp/base.php"
|
|
37
37
|
contains = "namespace think;"
|
|
38
38
|
exclude_subpaths = ["runtime/cache"]
|
|
39
|
+
|
|
40
|
+
# CodeIgniter 3 writes generated PHP-guarded log records in application/logs.
|
|
41
|
+
# Keep application controllers and framework source under this root eligible.
|
|
42
|
+
[[framework]]
|
|
43
|
+
name = "codeigniter3"
|
|
44
|
+
marker = "system/core/CodeIgniter.php"
|
|
45
|
+
contains = "const CI_VERSION = '3."
|
|
46
|
+
exclude_subpaths = ["application/logs"]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cobraphp
|
|
3
|
-
Version: 0.1.0.
|
|
3
|
+
Version: 0.1.0.dev8
|
|
4
4
|
Summary: Placeholder for the Python interface of CobraPHP, a static taint analyzer for PHP projects.
|
|
5
5
|
License-Expression: GPL-2.0-only
|
|
6
|
-
Requires-Python: >=3.11
|
|
6
|
+
Requires-Python: >=3.11.5
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
License-File: LICENSE
|
|
9
9
|
Requires-Dist: cpg2py==1.2.2
|
|
10
|
-
Requires-Dist: php-parser-py==
|
|
10
|
+
Requires-Dist: php-parser-py==3.0.1
|
|
11
11
|
Requires-Dist: semgrep==1.85.0
|
|
12
12
|
Requires-Dist: setuptools<82
|
|
13
13
|
Dynamic: license-file
|
|
@@ -32,7 +32,7 @@ uv sync
|
|
|
32
32
|
|
|
33
33
|
`uv sync` installs the package, its dependencies at the versions of `uv.lock` and the check tools. The analysis starts the `semgrep` program of the scripts directory of the running Python environment, and the first one on `PATH` only when that directory lacks it, so the caller's `PATH` need not hold that directory.
|
|
34
34
|
|
|
35
|
-
The planned release wheel will bundle the CobraPHP jar. Which Java runtime it uses is undecided ([open gaps](docs/design.md#open-gaps)). Python 3.11 or later.
|
|
35
|
+
The planned release wheel will bundle the CobraPHP jar. Which Java runtime it uses is undecided ([open gaps](docs/design.md#open-gaps)). Python 3.11.5 or later.
|
|
36
36
|
|
|
37
37
|
## Examples
|
|
38
38
|
|
|
@@ -10,22 +10,22 @@ cobraphp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
10
10
|
cobraphp/results.py,sha256=fc5CUVPZ__SDdKyxQ1UyQJt3FSM6yfzOfaBCGL1Wtss,3055
|
|
11
11
|
cobraphp/analysis/__init__.py,sha256=s-5zkF4CmBl-WwB97kUF7Jws8oW49zNpVJQwhLcBzIQ,3197
|
|
12
12
|
cobraphp/analysis/_ast_types.py,sha256=vi0gkMxFHLDK7Jd_Qgj1h5iVf9BTGR2x5OhOtIkkq5E,926
|
|
13
|
-
cobraphp/analysis/_call_builder.py,sha256=
|
|
13
|
+
cobraphp/analysis/_call_builder.py,sha256=g1PDH1W--dPMDU7fqNHtvNFf0dHOQrn4iAeY1e0ZgaE,5353
|
|
14
14
|
cobraphp/analysis/_call_graph.py,sha256=nlo_8VCvc5JzVTrH7MMicbT49Rgwd-EuAewLrJoALx8,8081
|
|
15
15
|
cobraphp/analysis/_call_graph_nodes.py,sha256=MuXtGdNe4iNals-0yPeLhykdxEr1JEjk1h_YypLLIaA,6205
|
|
16
|
-
cobraphp/analysis/_callee_index.py,sha256=
|
|
16
|
+
cobraphp/analysis/_callee_index.py,sha256=Xe182lfniuDRLO5SikQxZBmvjhEWp22xMDl72KtQGek,5854
|
|
17
17
|
cobraphp/analysis/_database_write_reach.py,sha256=7QX01xuwbOR-Z4G5_y9T2NZY5ctk_s2RtpthCEIxDaI,9255
|
|
18
18
|
cobraphp/analysis/_database_writes.py,sha256=-CbUA1ox3nmhbBJjY5VL0BYkCtabcfrrvp7AeRZ2uaY,75811
|
|
19
|
-
cobraphp/analysis/_declarations.py,sha256=
|
|
19
|
+
cobraphp/analysis/_declarations.py,sha256=_ex7gSD6sTyKWv38SjuC66qNkUDz4_pYukKPE9_9as0,1122
|
|
20
20
|
cobraphp/analysis/_defuse_assignments.py,sha256=f_LrdQeNExdSpGsadjKETd4GI97HC_64C3Qq4BAbO-c,1466
|
|
21
|
-
cobraphp/analysis/_defuse_builder.py,sha256=
|
|
21
|
+
cobraphp/analysis/_defuse_builder.py,sha256=Jvbe9micUGx4oEQYK6ZM9PJya_HJL24pvB_mpIAQY1Q,10969
|
|
22
22
|
cobraphp/analysis/_defuse_interproc.py,sha256=kNBICZkbYxEwtLtPfkxEPsNe_aHN_rHQ8K-n4OANOSw,4749
|
|
23
23
|
cobraphp/analysis/_defuse_values.py,sha256=1T2D6T4XWz1mK1y_fkw5h5WUlI1c-rlOG7X0X6GwP54,3210
|
|
24
24
|
cobraphp/analysis/_errors.py,sha256=cn71QQpesqbkitJdkg9bMIcvXlPixRxol7CjOMZM0i0,531
|
|
25
25
|
cobraphp/analysis/_file_filter.py,sha256=8z9-2ZANnjRGqDbnP6UQcUf0Hpjf_4C72yTgC8cqcDw,6056
|
|
26
26
|
cobraphp/analysis/_functions.py,sha256=NoBHi4XBbjSeKZ-dQESznpWCPe-6smNvmy5NChOXkCk,5781
|
|
27
27
|
cobraphp/analysis/_node_order.py,sha256=LkPGeKxE1b06rPOCSUqnKXYqEMHjPx45oXVjkjRQ2mA,1699
|
|
28
|
-
cobraphp/analysis/_parsing.py,sha256=
|
|
28
|
+
cobraphp/analysis/_parsing.py,sha256=Jsl493UBszuWqz5j0xPyLmdk8rVHuHDyZ88_iau-F8c,1783
|
|
29
29
|
cobraphp/analysis/_project_root.py,sha256=cuS_sOGZBqDp5H6HWn_xLaxAyVlsfxwADgc0MheC-fY,1050
|
|
30
30
|
cobraphp/analysis/_records.py,sha256=ZTC9RCL1DoOi7ctLvBk6P10QqXaOqdxoNX776UUuuRE,6026
|
|
31
31
|
cobraphp/analysis/_semgrep_runner.py,sha256=HwLfxi3Ql86IRQhyNvvtoa-uOPkWF168GfGed7d8_SA,14588
|
|
@@ -35,12 +35,12 @@ cobraphp/analysis/_taint_propagator.py,sha256=xmP_3G9T5Sgeie7yeq6Fca9bUsRyOnnwYz
|
|
|
35
35
|
cobraphp/analysis/_taint_rules.py,sha256=b77hFwh6zURdqfx6jWZwTbS24hE03t7wtlYEckgaO5I,4822
|
|
36
36
|
cobraphp/analysis/_value_dependency.py,sha256=AlMPHJLaEyMfdUeaDe2w3b9M5MU37_Jz8eEvYVG6Mq0,4333
|
|
37
37
|
cobraphp/analysis/database_writes.toml,sha256=zeQbntZ5T6LbkIag6--v5uplnfHxGuT-FyNqpvwCgWY,18797
|
|
38
|
-
cobraphp/analysis/frameworks.toml,sha256=
|
|
38
|
+
cobraphp/analysis/frameworks.toml,sha256=1DOuupZ5vpIsSxygKywFA3d6jElGvn6-fL2_wsuBu04,2193
|
|
39
39
|
cobraphp/analysis/php_ast_types.toml,sha256=yMtPKzOHDY9nm6NCKtMzxziug1z29kC3rSfh2bk46DM,1598
|
|
40
40
|
cobraphp/analysis/rules/database_taint.yaml,sha256=xCx64v2RjponPfEYZOQUqSqP_ltV8YB-t5NldjOstcI,3495
|
|
41
41
|
cobraphp/analysis/rules/user_input_taint.yaml,sha256=47nknffSg_wIKGPg8Ya-r4POa4nWswopju2IEkcFvtc,6998
|
|
42
|
-
cobraphp-0.1.0.
|
|
43
|
-
cobraphp-0.1.0.
|
|
44
|
-
cobraphp-0.1.0.
|
|
45
|
-
cobraphp-0.1.0.
|
|
46
|
-
cobraphp-0.1.0.
|
|
42
|
+
cobraphp-0.1.0.dev8.dist-info/licenses/LICENSE,sha256=-cN1ob5KQfe3AwHdg8kcuJ5BVnR4hZt37vN1pS14JQU,18091
|
|
43
|
+
cobraphp-0.1.0.dev8.dist-info/METADATA,sha256=wViDAWn01uDA3F7uAzjvIGUcsQSZBBmWNwty1lXLZXk,6822
|
|
44
|
+
cobraphp-0.1.0.dev8.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
45
|
+
cobraphp-0.1.0.dev8.dist-info/top_level.txt,sha256=55CayiaOZMnPngJQf8IqO50E-l0BQONI8DTpnn-gtJk,9
|
|
46
|
+
cobraphp-0.1.0.dev8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|