MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / main

Function main

scripts/license-gate-check.py:14–49  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12
13
14def main():
15 scan_path, policy_path = sys.argv[1], sys.argv[2]
16 with open(policy_path) as fh:
17 policy = json.load(fh)
18 allowed = {x.lower() for x in policy["allowed_spdx_ids"]}
19 ignored_paths = tuple(policy.get("ignored_paths", []))
20 skip_tokens = {"and", "or", "with", ""}
21
22 with open(scan_path) as fh:
23 scan = json.load(fh)
24
25 violations = []
26 checked = 0
27 for f in scan.get("files", []):
28 path = f.get("path", "?")
29 if f.get("type") != "file":
30 continue
31 if ignored_paths and path.startswith(ignored_paths):
32 continue
33 expr = f.get("detected_license_expression_spdx")
34 if not expr:
35 continue
36 checked += 1
37 for tok in re.split(r"[\s()]+", expr):
38 if tok.lower() in skip_tokens:
39 continue
40 if tok.lower() not in allowed:
41 violations.append((path, expr, tok))
42 break
43
44 if violations:
45 print("BLOCKED: %d file(s) with non-allow-listed license detections:" % len(violations))
46 for path, expr, tok in violations[:25]:
47 print(" %s: '%s' (offending id: %s)" % (path, expr, tok))
48 sys.exit(1)
49 print("OK: %d detection(s), all allow-listed" % checked)
50
51
52if __name__ == "__main__":

Callers 1

Calls 3

loadMethod · 0.80
getMethod · 0.65
openFunction · 0.50

Tested by

no test coverage detected