Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/skillspector/nested_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,36 @@
".bash",
".bat",
".bin",
".cjs",
".cmd",
".com",
".cts",
".dll",
".dylib",
".exe",
".go",
".js",
".jsx",
".mjs",
".msi",
".mts",
".php",
".php3",
".php4",
".php5",
".phtml",
".pl",
".ps1",
".py",
".pyc",
".pyo",
".rake",
".rb",
".rs",
".sh",
".so",
".ts",
".tsx",
".zsh",
}
)
Expand Down
21 changes: 20 additions & 1 deletion tests/nodes/test_nested_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from skillspector.artifacts import ArtifactDisposition, ContentKind
from skillspector.inspection_ledger import LedgerOutcome, LedgerReason
from skillspector.nested_artifacts import inspect_nested_artifacts
from skillspector.nested_artifacts import inspect_nested_artifacts, is_executable_content
from skillspector.nodes.analyzers.static_patterns_supply_chain import (
_analyze_concealed_executables,
)
Expand Down Expand Up @@ -828,3 +828,22 @@ def test_reserved_virtual_delimiter_cannot_collide_with_recursive_provenance(
event.get("reason_code") == LedgerReason.ARCHIVE_UNSAFE_MEMBER_PATH
for event in result.ledger_events
)


@pytest.mark.parametrize(
"suffix",
[".cjs", ".cts", ".jsx", ".mjs", ".mts", ".tsx", ".php", ".phtml", ".rake"],
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One concrete false-positive edge remains: Path(path).suffix classifies types.d.cts and types.d.mts as executable even though those are TypeScript declaration files, not runtime implementations. I recommend explicitly excluding .d.cts and .d.mts and adding regression tests. Apart from that declaration-file case, I did not find an added suffix that is wholly unrelated to executable code.

Please handle this @MohammedAlkindi

def test_analyzer_recognized_script_suffixes_classify_as_executable(suffix: str) -> None:
assert is_executable_content("helper" + suffix, b"payload without a shebang") is True


def test_hidden_standalone_esm_script_has_sc9_and_stays_local(tmp_path: Path) -> None:
(tmp_path / ".setup.mjs").write_text('import cp from "child_process";', encoding="utf-8")

context = build_context({"skill_path": str(tmp_path)})
findings = _analyze_concealed_executables(context["component_metadata"])

assert ".setup.mjs" in context["components"]
assert len(findings) == 1
assert findings[0].file == ".setup.mjs"
Loading