исправить: закрыть ревью сквозной корреляции
This commit is contained in:
@@ -20,6 +20,11 @@ DEFAULT_EXCLUDED_PREFIXES = {
|
||||
"apps/ui/dist/",
|
||||
}
|
||||
|
||||
ALLOW_DIRECTIVE = re.compile(
|
||||
r"community-scope:\s*allow=([a-z0-9-]+(?:,[a-z0-9-]+)*)",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
FORBIDDEN_PATTERNS = [
|
||||
("enterprise", re.compile(r"\benterprise\b", re.IGNORECASE)),
|
||||
("cloud", re.compile(r"\bcloud\b", re.IGNORECASE)),
|
||||
@@ -100,7 +105,15 @@ def scan_file(root: Path, relative_path: str) -> list[str]:
|
||||
text = data.decode("utf-8", errors="replace")
|
||||
findings: list[str] = []
|
||||
for line_no, line in enumerate(text.splitlines(), start=1):
|
||||
directive = ALLOW_DIRECTIVE.search(line)
|
||||
allowed_markers = (
|
||||
{label.lower() for label in directive.group(1).split(",")}
|
||||
if directive
|
||||
else set()
|
||||
)
|
||||
for label, pattern in FORBIDDEN_PATTERNS:
|
||||
if label in allowed_markers:
|
||||
continue
|
||||
if pattern.search(line):
|
||||
findings.append(f"{relative_path}:{line_no}: forbidden marker `{label}`")
|
||||
return findings
|
||||
|
||||
Reference in New Issue
Block a user