mirror of
https://github.com/norandom/OpenUltraSAST.git
synced 2026-10-20 05:29:28 +00:00
engine: admit TypeScript (jssrc2cpg, JavaScript taint specs via one alias), .mts/.cts, mixed JS/TS builds one CPG
Implemented with Codex. Not merged: wall-clock deadline tests failed at host load 47; to be re-checked against main at normal load. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
20777d8863
commit
e13ce35a75
@@ -15,12 +15,14 @@ from ..ruleset.frameworks import Priors, kept, normalize_priors, read_tag, tag_o
|
||||
|
||||
DEFAULT_FACTS_DIR = Path(__file__).resolve().parents[1] / "ruleset" / "semantic"
|
||||
|
||||
TAINT_LANGUAGE_ALIAS = {"typescript": "javascript"}
|
||||
|
||||
_LANGUAGE_ALIASES = {
|
||||
"c": "c",
|
||||
"cpp": "c",
|
||||
"python": "python",
|
||||
"javascript": "javascript",
|
||||
"typescript": "javascript",
|
||||
**TAINT_LANGUAGE_ALIAS,
|
||||
"java": "java",
|
||||
}
|
||||
|
||||
@@ -145,8 +147,18 @@ class SemanticFacts:
|
||||
dispatches: tuple[DispatchFact, ...] = ()
|
||||
layouts: tuple[LayoutFact, ...] = ()
|
||||
|
||||
def taint_language(self, language: str) -> str:
|
||||
"""Prefer native facts when supplied; otherwise use the shared language aliases."""
|
||||
if language in TAINT_LANGUAGE_ALIAS and any(
|
||||
item.language == language
|
||||
for items in (self.sources, self.sinks, self.sanitizers, self.dispatches, self.layouts)
|
||||
for item in items
|
||||
):
|
||||
return language
|
||||
return _LANGUAGE_ALIASES.get(language, language)
|
||||
|
||||
def for_language(self, language: str) -> SemanticFacts:
|
||||
key = _LANGUAGE_ALIASES.get(language, language)
|
||||
key = self.taint_language(language)
|
||||
return SemanticFacts(
|
||||
version=self.version,
|
||||
sources=tuple(item for item in self.sources if item.language == key),
|
||||
|
||||
Reference in New Issue
Block a user