stackparity 1.0.0__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.
Files changed (212) hide show
  1. stackparity/__init__.py +17 -0
  2. stackparity/_engine/agents/investigator.py +294 -0
  3. stackparity/_engine/agents/memory_agent.py +37 -0
  4. stackparity/_engine/agents/pipeline_agent.py +152 -0
  5. stackparity/_engine/agents/remediation_agent.py +248 -0
  6. stackparity/_engine/agents/runtime.py +177 -0
  7. stackparity/_engine/agents/specialists.py +709 -0
  8. stackparity/_engine/agents/suspicious_change_agent.py +1275 -0
  9. stackparity/_engine/cli/__init__.py +2 -0
  10. stackparity/_engine/cli/main.py +1252 -0
  11. stackparity/_engine/cli/remediate.py +461 -0
  12. stackparity/_engine/cli/term.py +44 -0
  13. stackparity/_engine/config/__init__.py +0 -0
  14. stackparity/_engine/config/constants.py +88 -0
  15. stackparity/_engine/config/loader.py +155 -0
  16. stackparity/_engine/config/settings.py +108 -0
  17. stackparity/_engine/containers/__init__.py +12 -0
  18. stackparity/_engine/containers/discovery.py +143 -0
  19. stackparity/_engine/containers/models.py +72 -0
  20. stackparity/_engine/containers/trivy_image_scanner.py +165 -0
  21. stackparity/_engine/core/__init__.py +0 -0
  22. stackparity/_engine/core/capabilities.py +107 -0
  23. stackparity/_engine/core/finding_schema.py +305 -0
  24. stackparity/_engine/core/git_manager.py +206 -0
  25. stackparity/_engine/core/http.py +64 -0
  26. stackparity/_engine/core/models.py +109 -0
  27. stackparity/_engine/core/netpolicy.py +242 -0
  28. stackparity/_engine/core/plugins.py +43 -0
  29. stackparity/_engine/core/repository_inspector.py +243 -0
  30. stackparity/_engine/core/safe_env.py +48 -0
  31. stackparity/_engine/core/scan_orchestrator.py +289 -0
  32. stackparity/_engine/core/scan_state.py +58 -0
  33. stackparity/_engine/core/url_validator.py +135 -0
  34. stackparity/_engine/ecosystems/__init__.py +1 -0
  35. stackparity/_engine/ecosystems/registry.py +138 -0
  36. stackparity/_engine/evidence/__init__.py +1 -0
  37. stackparity/_engine/evidence/store.py +65 -0
  38. stackparity/_engine/explainability/__init__.py +0 -0
  39. stackparity/_engine/explainability/evidence_formatter.py +30 -0
  40. stackparity/_engine/explainability/explanation_engine.py +132 -0
  41. stackparity/_engine/explainability/explanation_validator.py +54 -0
  42. stackparity/_engine/explainability/prompt_templates.py +18 -0
  43. stackparity/_engine/graph/__init__.py +0 -0
  44. stackparity/_engine/graph/dependency_tracer.py +86 -0
  45. stackparity/_engine/graph/graph_builder.py +165 -0
  46. stackparity/_engine/graph/graph_diff.py +57 -0
  47. stackparity/_engine/graph/graph_exporter.py +194 -0
  48. stackparity/_engine/graph/graph_validator.py +46 -0
  49. stackparity/_engine/graph/impact_analyzer.py +23 -0
  50. stackparity/_engine/graph/tree_view.py +185 -0
  51. stackparity/_engine/intel/__init__.py +0 -0
  52. stackparity/_engine/intel/epss.py +53 -0
  53. stackparity/_engine/llm/__init__.py +1 -0
  54. stackparity/_engine/llm/client.py +138 -0
  55. stackparity/_engine/monitor/__init__.py +0 -0
  56. stackparity/_engine/monitor/watch.py +171 -0
  57. stackparity/_engine/non_cve/__init__.py +7 -0
  58. stackparity/_engine/non_cve/base.py +62 -0
  59. stackparity/_engine/non_cve/iac.py +144 -0
  60. stackparity/_engine/non_cve/sast.py +272 -0
  61. stackparity/_engine/non_cve/supply_chain.py +147 -0
  62. stackparity/_engine/orchestration/__init__.py +1 -0
  63. stackparity/_engine/orchestration/pipeline.py +279 -0
  64. stackparity/_engine/orchestration/supervisor.py +167 -0
  65. stackparity/_engine/pipeline_analysis/__init__.py +0 -0
  66. stackparity/_engine/pipeline_analysis/analyzer.py +90 -0
  67. stackparity/_engine/pipeline_analysis/ci.py +189 -0
  68. stackparity/_engine/pipeline_analysis/ci_adapters/__init__.py +24 -0
  69. stackparity/_engine/pipeline_analysis/ci_adapters/azure_pipelines.py +221 -0
  70. stackparity/_engine/pipeline_analysis/ci_adapters/base.py +239 -0
  71. stackparity/_engine/pipeline_analysis/ci_adapters/circleci.py +176 -0
  72. stackparity/_engine/pipeline_analysis/ci_adapters/github_actions.py +356 -0
  73. stackparity/_engine/pipeline_analysis/ci_adapters/gitlab_ci.py +268 -0
  74. stackparity/_engine/pipeline_analysis/ci_adapters/jenkins.py +180 -0
  75. stackparity/_engine/pipeline_analysis/ci_adapters/registry.py +80 -0
  76. stackparity/_engine/pipeline_analysis/ci_models.py +72 -0
  77. stackparity/_engine/pipeline_analysis/dockerfile.py +235 -0
  78. stackparity/_engine/pipeline_analysis/eol.py +62 -0
  79. stackparity/_engine/pipeline_analysis/models.py +37 -0
  80. stackparity/_engine/policy/__init__.py +0 -0
  81. stackparity/_engine/policy/engine.py +216 -0
  82. stackparity/_engine/policy/resources/default.yaml +56 -0
  83. stackparity/_engine/policy/resources/strict.yaml +35 -0
  84. stackparity/_engine/reachability/__init__.py +0 -0
  85. stackparity/_engine/reachability/app_reachability.py +186 -0
  86. stackparity/_engine/reachability/scanners.py +215 -0
  87. stackparity/_engine/remediation/__init__.py +0 -0
  88. stackparity/_engine/remediation/adapters.py +198 -0
  89. stackparity/_engine/remediation/apply_local.py +309 -0
  90. stackparity/_engine/remediation/code_fixes.py +383 -0
  91. stackparity/_engine/remediation/compat.py +156 -0
  92. stackparity/_engine/remediation/container_plan.py +127 -0
  93. stackparity/_engine/remediation/delivery.py +31 -0
  94. stackparity/_engine/remediation/export.py +44 -0
  95. stackparity/_engine/remediation/lifecycle.py +623 -0
  96. stackparity/_engine/remediation/local_trial.py +358 -0
  97. stackparity/_engine/remediation/patchers.py +215 -0
  98. stackparity/_engine/remediation/planner.py +285 -0
  99. stackparity/_engine/remediation/pr_template_engine.py +234 -0
  100. stackparity/_engine/remediation/reachability_impact.py +147 -0
  101. stackparity/_engine/remediation/versions.py +92 -0
  102. stackparity/_engine/remediation/whatif.py +64 -0
  103. stackparity/_engine/remediation/worktree_pr.py +434 -0
  104. stackparity/_engine/reporting/__init__.py +0 -0
  105. stackparity/_engine/reporting/counts.py +63 -0
  106. stackparity/_engine/reporting/fix_pdf.py +343 -0
  107. stackparity/_engine/reporting/fix_report.py +135 -0
  108. stackparity/_engine/reporting/json_exporter.py +61 -0
  109. stackparity/_engine/reporting/report_generator.py +200 -0
  110. stackparity/_engine/reporting/sarif.py +71 -0
  111. stackparity/_engine/reporting/vex.py +57 -0
  112. stackparity/_engine/reporting/view.py +166 -0
  113. stackparity/_engine/risk_analysis/__init__.py +0 -0
  114. stackparity/_engine/risk_analysis/contextual_scorer.py +253 -0
  115. stackparity/_engine/risk_analysis/evidence_collector.py +62 -0
  116. stackparity/_engine/risk_analysis/evidence_normalizer.py +37 -0
  117. stackparity/_engine/risk_analysis/finding_correlator.py +90 -0
  118. stackparity/_engine/risk_analysis/function_impact.py +184 -0
  119. stackparity/_engine/risk_analysis/production_context.py +252 -0
  120. stackparity/_engine/risk_analysis/risk_rules.py +81 -0
  121. stackparity/_engine/risk_analysis/risk_scorer.py +390 -0
  122. stackparity/_engine/sandbox/__init__.py +0 -0
  123. stackparity/_engine/sandbox/runner.py +142 -0
  124. stackparity/_engine/sbom/__init__.py +0 -0
  125. stackparity/_engine/sbom/adapters/__init__.py +19 -0
  126. stackparity/_engine/sbom/adapters/builtin.py +29 -0
  127. stackparity/_engine/sbom/adapters/syft.py +26 -0
  128. stackparity/_engine/sbom/adapters/trivy.py +76 -0
  129. stackparity/_engine/sbom/builtin_generator.py +227 -0
  130. stackparity/_engine/sbom/cyclonedx_validator.py +166 -0
  131. stackparity/_engine/sbom/exporters.py +153 -0
  132. stackparity/_engine/sbom/fusion/__init__.py +5 -0
  133. stackparity/_engine/sbom/fusion/engine.py +315 -0
  134. stackparity/_engine/sbom/fusion/hashes.py +47 -0
  135. stackparity/_engine/sbom/fusion/ledger.py +96 -0
  136. stackparity/_engine/sbom/fusion/registries.py +271 -0
  137. stackparity/_engine/sbom/fusion/resolver.py +143 -0
  138. stackparity/_engine/sbom/fusion/writer.py +114 -0
  139. stackparity/_engine/sbom/lockfile_analyzer.py +114 -0
  140. stackparity/_engine/sbom/merge.py +71 -0
  141. stackparity/_engine/sbom/package_extractors/common.py +104 -0
  142. stackparity/_engine/sbom/package_extractors/manifests.py +101 -0
  143. stackparity/_engine/sbom/package_extractors/npm.py +206 -0
  144. stackparity/_engine/sbom/package_extractors/others.py +267 -0
  145. stackparity/_engine/sbom/package_extractors/python.py +143 -0
  146. stackparity/_engine/sbom/quality_analyzer.py +191 -0
  147. stackparity/_engine/sbom/scanner_engine.py +98 -0
  148. stackparity/_engine/sbom/syft_runner.py +100 -0
  149. stackparity/_engine/sbom/tool_locator.py +69 -0
  150. stackparity/_engine/sbom/trivy_runner.py +82 -0
  151. stackparity/_engine/storage/__init__.py +0 -0
  152. stackparity/_engine/storage/cache.py +56 -0
  153. stackparity/_engine/storage/database.py +295 -0
  154. stackparity/_engine/storage/memory.py +146 -0
  155. stackparity/_engine/suspicious_changes/__init__.py +12 -0
  156. stackparity/_engine/suspicious_changes/analyzer.py +1022 -0
  157. stackparity/_engine/suspicious_changes/change_correlation.py +861 -0
  158. stackparity/_engine/suspicious_changes/lifecycle_script_detector.py +263 -0
  159. stackparity/_engine/suspicious_changes/lockfile_change_detector.py +316 -0
  160. stackparity/_engine/suspicious_changes/manifest_diff_detector.py +251 -0
  161. stackparity/_engine/suspicious_changes/package_risk.py +78 -0
  162. stackparity/_engine/suspicious_changes/popular_packages.py +94 -0
  163. stackparity/_engine/suspicious_changes/registry_detector.py +354 -0
  164. stackparity/_engine/suspicious_changes/suspicious_models.py +57 -0
  165. stackparity/_engine/suspicious_changes/typosquatting_detector.py +298 -0
  166. stackparity/_engine/tools/__init__.py +1 -0
  167. stackparity/_engine/tools/builtin.py +93 -0
  168. stackparity/_engine/tools/registry.py +66 -0
  169. stackparity/_engine/ui/__init__.py +0 -0
  170. stackparity/_engine/ui/components/__init__.py +0 -0
  171. stackparity/_engine/ui/components/common.py +238 -0
  172. stackparity/_engine/ui/components/live_progress.py +157 -0
  173. stackparity/_engine/ui/components/memory_panel.py +82 -0
  174. stackparity/_engine/ui/pages/__init__.py +0 -0
  175. stackparity/_engine/ui/pages/agents_page.py +76 -0
  176. stackparity/_engine/ui/pages/architecture_page.py +44 -0
  177. stackparity/_engine/ui/pages/fixes_page.py +98 -0
  178. stackparity/_engine/ui/pages/graph_page.py +203 -0
  179. stackparity/_engine/ui/pages/health_page.py +117 -0
  180. stackparity/_engine/ui/pages/monitor_page.py +67 -0
  181. stackparity/_engine/ui/pages/pipeline_page.py +219 -0
  182. stackparity/_engine/ui/pages/remediation_page.py +409 -0
  183. stackparity/_engine/ui/pages/reports_page.py +54 -0
  184. stackparity/_engine/ui/pages/sbom_page.py +210 -0
  185. stackparity/_engine/ui/pages/scan_page.py +131 -0
  186. stackparity/_engine/ui/pages/suspicious_page.py +551 -0
  187. stackparity/_engine/ui/pages/vulns_page.py +201 -0
  188. stackparity/_engine/ui/state.py +116 -0
  189. stackparity/_engine/ui/theme.py +201 -0
  190. stackparity/_engine/ui/visualizations/__init__.py +0 -0
  191. stackparity/_engine/ui/visualizations/graphs.py +373 -0
  192. stackparity/_engine/vulnerability/__init__.py +0 -0
  193. stackparity/_engine/vulnerability/cvss.py +58 -0
  194. stackparity/_engine/vulnerability/kev_client.py +47 -0
  195. stackparity/_engine/vulnerability/nvd_client.py +74 -0
  196. stackparity/_engine/vulnerability/osv_client.py +139 -0
  197. stackparity/_engine/vulnerability/remediation_engine.py +50 -0
  198. stackparity/_engine/vulnerability/verification.py +94 -0
  199. stackparity/_engine/vulnerability/version_matcher.py +299 -0
  200. stackparity/_engine/vulnerability/vulnerability_correlator.py +303 -0
  201. stackparity/_engine/vulnerability/vulnerability_models.py +64 -0
  202. stackparity/cli.py +30 -0
  203. stackparity/dashboard_app.py +95 -0
  204. stackparity/web_dist/assets/index-DRJYw2Du.css +1 -0
  205. stackparity/web_dist/assets/index-Q6LLpbEi.js +495 -0
  206. stackparity/web_dist/index.html +13 -0
  207. stackparity/web_server.py +533 -0
  208. stackparity-1.0.0.dist-info/METADATA +204 -0
  209. stackparity-1.0.0.dist-info/RECORD +212 -0
  210. stackparity-1.0.0.dist-info/WHEEL +4 -0
  211. stackparity-1.0.0.dist-info/entry_points.txt +2 -0
  212. stackparity-1.0.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,180 @@
1
+ """Jenkins pipeline adapter supporting Declarative and Scripted pipelines."""
2
+ from __future__ import annotations
3
+
4
+ import re
5
+ from typing import Any, Optional
6
+
7
+ from pipeline_analysis.ci_adapters.base import BaseCIAdapter
8
+ from pipeline_analysis.ci_models import CIDockerBuild, UnifiedJob, UnifiedPipeline, UnifiedStep
9
+ from pipeline_analysis.dockerfile import INSECURE, PIPE_TO_SHELL
10
+ from pipeline_analysis.models import PipelineFinding
11
+
12
+ JENKINS_FILE_RE = re.compile(r"(^|/)(Jenkinsfile(\..*)?|.*\.jenkinsfile)$", re.IGNORECASE)
13
+ DOCKER_AGENT_IMG_RE = re.compile(
14
+ r"""(?:agent\s*\{\s*docker\s*\{\s*image\s*['"]([^'"]+)['"]|docker\.image\(\s*['"]([^'"]+)['"]\))""",
15
+ re.IGNORECASE,
16
+ )
17
+ JENKINS_STAGE_RE = re.compile(r"""stage\(\s*['"]([^'"]+)['"]\s*\)""", re.IGNORECASE)
18
+ JENKINS_SH_RE = re.compile(r"""\b(?:sh|bat|powershell)\s+(?:['"]([^'"]+)['"]|""" + r'"""(.*?)""")' , re.DOTALL)
19
+ DOCKER_METHOD_BUILD_RE = re.compile(
20
+ r"""docker\.build\(\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*\)""",
21
+ re.IGNORECASE,
22
+ )
23
+
24
+
25
+ class JenkinsCIAdapter(BaseCIAdapter):
26
+ """Adapter for Jenkins Declarative and Scripted pipelines."""
27
+
28
+ @property
29
+ def platform_id(self) -> str:
30
+ return "jenkins"
31
+
32
+ @property
33
+ def platform_name(self) -> str:
34
+ return "Jenkins"
35
+
36
+ def can_handle(self, file_path: str) -> bool:
37
+ norm = file_path.replace("\\", "/")
38
+ return bool(JENKINS_FILE_RE.search(norm))
39
+
40
+ def analyze(self, text: str, file_path: str) -> UnifiedPipeline:
41
+ pipeline = UnifiedPipeline(platform=self.platform_id, file_path=file_path)
42
+ lines = text.splitlines()
43
+
44
+ # Extract Docker agent images
45
+ for m in DOCKER_AGENT_IMG_RE.finditer(text):
46
+ img = m.group(1) or m.group(2)
47
+ if img:
48
+ ln = self._find_line(lines, img)
49
+ im_dict = self._normalize_image_dict(img, file_path, ln, "agent")
50
+ pipeline.container_images.append(im_dict)
51
+
52
+ if not im_dict.get("digest") and im_dict.get("tag") in (None, "latest"):
53
+ pipeline.findings.append(
54
+ self._create_finding(
55
+ "JNK001",
56
+ f"Jenkins Docker agent uses unpinned image '{img}'",
57
+ "MEDIUM",
58
+ file_path,
59
+ ln,
60
+ f"image '{img}'",
61
+ img,
62
+ "Floating or latest tags pull modified upstream images without notification.",
63
+ "Pin an explicit version and image digest: `image 'myorg/build:1.0.0@sha256:...'`.",
64
+ )
65
+ )
66
+
67
+ # Extract stages
68
+ current_job: Optional[UnifiedJob] = None
69
+ stages_found: list[str] = []
70
+
71
+ for n, raw_line in enumerate(lines, 1):
72
+ line = raw_line.strip()
73
+
74
+ # Detect stage declaration
75
+ m_stage = JENKINS_STAGE_RE.search(line)
76
+ if m_stage:
77
+ sname = m_stage.group(1)
78
+ stages_found.append(sname)
79
+ current_job = UnifiedJob(name=sname, stage=sname)
80
+ pipeline.jobs[sname] = current_job
81
+
82
+ # Shell step checks
83
+ if re.search(r"\b(?:sh|bat|powershell)\b", line):
84
+ if current_job:
85
+ current_job.steps.append(UnifiedStep(name="shell", command=line, line=n))
86
+
87
+ if PIPE_TO_SHELL.search(line):
88
+ pipeline.findings.append(
89
+ self._create_finding(
90
+ "JNK002",
91
+ "Remote script is piped to shell in Jenkins step",
92
+ "HIGH",
93
+ file_path,
94
+ n,
95
+ line,
96
+ "curl|sh",
97
+ "Executes arbitrary code downloaded over the network with Jenkins agent privileges.",
98
+ "Download to a file, verify a checksum/signature, then run.",
99
+ )
100
+ )
101
+
102
+ if INSECURE.search(line):
103
+ pipeline.findings.append(
104
+ self._create_finding(
105
+ "JNK005",
106
+ "TLS verification disabled in Jenkins shell step",
107
+ "MEDIUM",
108
+ file_path,
109
+ n,
110
+ line,
111
+ "insecure",
112
+ "Disabling TLS verification permits tampering with downloaded tools or dependencies.",
113
+ "Remove `--insecure` or `-k` flags from curl/wget commands.",
114
+ )
115
+ )
116
+
117
+ # Script injection through Groovy GString interpolation: sh "echo ${params.FOO}"
118
+ if re.search(r'sh\s+"[^"]*\$\{params\.[^"]*\}"', line):
119
+ pipeline.findings.append(
120
+ self._create_finding(
121
+ "JNK004",
122
+ "Unsafe Groovy string interpolation with build params inside `sh` step",
123
+ "HIGH",
124
+ file_path,
125
+ n,
126
+ line,
127
+ "params-interpolation",
128
+ "GString double-quote interpolation executes before passing the command to shell, permitting shell injection via user parameters.",
129
+ "Use single quotes with environment variables: `sh 'echo $PARAM_NAME'`.",
130
+ evidence_strength="high",
131
+ )
132
+ )
133
+
134
+ # Plain credentials passed directly without withCredentials
135
+ if re.search(r"\b(?:password|passwd|secret_key|api_key)\s*=\s*['\"][^'\"]+['\"]", line, re.I):
136
+ pipeline.findings.append(
137
+ self._create_finding(
138
+ "JNK003",
139
+ "Potential plain-text secret inside Jenkins step command",
140
+ "HIGH",
141
+ file_path,
142
+ n,
143
+ line,
144
+ "plain-secret",
145
+ "Passing raw credentials in shell commands exposes them to console logs and process tables.",
146
+ "Use `withCredentials` block to inject credentials securely.",
147
+ )
148
+ )
149
+
150
+ # Extract Docker builds in shell
151
+ builds = self._extract_docker_build_from_shell(
152
+ line, file_path, current_job.name if current_job else "global", n
153
+ )
154
+ if builds:
155
+ if current_job:
156
+ current_job.docker_builds.extend(builds)
157
+ pipeline.docker_builds.extend(builds)
158
+
159
+ # docker.build("tag", "args") method
160
+ m_db = DOCKER_METHOD_BUILD_RE.search(line)
161
+ if m_db:
162
+ tag = m_db.group(1)
163
+ args = m_db.group(2) or "."
164
+ cdb = CIDockerBuild(
165
+ dockerfile_path="Dockerfile",
166
+ context_path=args,
167
+ image_tag=tag,
168
+ builder_tool="jenkins-docker-plugin",
169
+ ci_file=file_path,
170
+ ci_job=current_job.name if current_job else "global",
171
+ line=n,
172
+ )
173
+ if current_job:
174
+ current_job.docker_builds.append(cdb)
175
+ pipeline.docker_builds.append(cdb)
176
+
177
+ pipeline.stages = stages_found
178
+ # Scan for committed secrets
179
+ pipeline.findings.extend(self._scan_secret_literals(lines, file_path))
180
+ return pipeline
@@ -0,0 +1,80 @@
1
+ """Registry and dispatcher for Multi-CI platform adapters."""
2
+ from __future__ import annotations
3
+
4
+ from typing import Optional
5
+
6
+ from pipeline_analysis.ci import analyze_generic_ci
7
+ from pipeline_analysis.ci_adapters.azure_pipelines import AzurePipelinesAdapter
8
+ from pipeline_analysis.ci_adapters.base import BaseCIAdapter
9
+ from pipeline_analysis.ci_adapters.circleci import CircleCIAdapter
10
+ from pipeline_analysis.ci_adapters.github_actions import GitHubActionsAdapter
11
+ from pipeline_analysis.ci_adapters.gitlab_ci import GitLabCIAdapter
12
+ from pipeline_analysis.ci_adapters.jenkins import JenkinsCIAdapter
13
+ from pipeline_analysis.ci_models import UnifiedPipeline
14
+
15
+
16
+ class GenericCIAdapter(BaseCIAdapter):
17
+ """Fallback adapter for unrecognized CI files."""
18
+
19
+ @property
20
+ def platform_id(self) -> str:
21
+ return "generic_ci"
22
+
23
+ @property
24
+ def platform_name(self) -> str:
25
+ return "CI (generic)"
26
+
27
+ def can_handle(self, file_path: str) -> bool:
28
+ return True
29
+
30
+ def analyze(self, text: str, file_path: str) -> UnifiedPipeline:
31
+ findings, images = analyze_generic_ci(text, file_path)
32
+ pipeline = UnifiedPipeline(
33
+ platform=self.platform_id,
34
+ file_path=file_path,
35
+ findings=findings,
36
+ container_images=images,
37
+ )
38
+ return pipeline
39
+
40
+
41
+ class CIAdapterRegistry:
42
+ """Registry managing available CI platform adapters."""
43
+
44
+ def __init__(self) -> None:
45
+ self._adapters: list[BaseCIAdapter] = [
46
+ GitHubActionsAdapter(),
47
+ GitLabCIAdapter(),
48
+ JenkinsCIAdapter(),
49
+ CircleCIAdapter(),
50
+ AzurePipelinesAdapter(),
51
+ ]
52
+ self._fallback = GenericCIAdapter()
53
+
54
+ def register_adapter(self, adapter: BaseCIAdapter) -> None:
55
+ """Register a new custom CI adapter at highest priority."""
56
+ self._adapters.insert(0, adapter)
57
+
58
+ def get_adapter(self, file_path: str) -> BaseCIAdapter:
59
+ """Return the first adapter that can handle file_path, or fallback."""
60
+ for adapter in self._adapters:
61
+ if adapter.can_handle(file_path):
62
+ return adapter
63
+ return self._fallback
64
+
65
+ def analyze_file(self, text: str, file_path: str) -> UnifiedPipeline:
66
+ """Find matching adapter and execute pipeline analysis."""
67
+ adapter = self.get_adapter(file_path)
68
+ return adapter.analyze(text, file_path)
69
+
70
+
71
+ # Global singleton instance
72
+ REGISTRY = CIAdapterRegistry()
73
+
74
+
75
+ def get_adapter_for_file(file_path: str) -> BaseCIAdapter:
76
+ return REGISTRY.get_adapter(file_path)
77
+
78
+
79
+ def analyze_ci_pipeline(text: str, file_path: str) -> UnifiedPipeline:
80
+ return REGISTRY.analyze_file(text, file_path)
@@ -0,0 +1,72 @@
1
+ """Unified domain models for Multi-CI pipeline analysis and container build extraction."""
2
+ from __future__ import annotations
3
+
4
+ from dataclasses import dataclass, field
5
+ from typing import Any, Literal, Optional
6
+
7
+ from pipeline_analysis.models import PipelineFinding
8
+
9
+ CIPlatform = Literal[
10
+ "github_actions",
11
+ "gitlab_ci",
12
+ "jenkins",
13
+ "circleci",
14
+ "azure_pipelines",
15
+ "generic_ci",
16
+ ]
17
+
18
+
19
+ @dataclass
20
+ class CIDockerBuild:
21
+ """Represents a container build directive discovered inside a CI pipeline."""
22
+ dockerfile_path: str = "Dockerfile"
23
+ context_path: str = "."
24
+ image_tag: Optional[str] = None
25
+ target_stage: Optional[str] = None
26
+ build_args: dict[str, str] = field(default_factory=dict)
27
+ builder_tool: str = "docker" # docker | kaniko | buildah | buildx | azure_task
28
+ ci_file: str = ""
29
+ ci_job: str = ""
30
+ line: int = 0
31
+
32
+
33
+ @dataclass
34
+ class UnifiedStep:
35
+ """A single step or command inside a CI job."""
36
+ name: str = ""
37
+ command: Optional[str] = None
38
+ uses: Optional[str] = None
39
+ task: Optional[str] = None
40
+ with_args: dict[str, Any] = field(default_factory=dict)
41
+ env: dict[str, str] = field(default_factory=dict)
42
+ line: int = 0
43
+
44
+
45
+ @dataclass
46
+ class UnifiedJob:
47
+ """A distinct execution job/stage within a CI pipeline."""
48
+ name: str
49
+ stage: str = "default"
50
+ runs_on: Optional[str] = None
51
+ container_image: Optional[str] = None
52
+ services: list[str] = field(default_factory=list)
53
+ steps: list[UnifiedStep] = field(default_factory=list)
54
+ docker_builds: list[CIDockerBuild] = field(default_factory=list)
55
+ extra: dict[str, Any] = field(default_factory=dict)
56
+
57
+
58
+ @dataclass
59
+ class UnifiedPipeline:
60
+ """Canonical representation of any CI pipeline across all supported platforms."""
61
+ platform: CIPlatform
62
+ file_path: str
63
+ stages: list[str] = field(default_factory=list)
64
+ jobs: dict[str, UnifiedJob] = field(default_factory=dict)
65
+ triggers: list[str] = field(default_factory=list)
66
+ docker_builds: list[CIDockerBuild] = field(default_factory=list)
67
+ external_dependencies: list[dict[str, Any]] = field(default_factory=list)
68
+ container_images: list[dict[str, Any]] = field(default_factory=list)
69
+ findings: list[PipelineFinding] = field(default_factory=list)
70
+ raw_parsed: dict[str, Any] = field(default_factory=dict)
71
+ parse_success: bool = True
72
+ error_message: Optional[str] = None
@@ -0,0 +1,235 @@
1
+ """Static Dockerfile / docker-compose analysis. Nothing is built or run; the files are only parsed."""
2
+ from __future__ import annotations
3
+
4
+ import re
5
+ from dataclasses import dataclass
6
+ from typing import Any, Optional
7
+
8
+ import yaml
9
+
10
+ from pipeline_analysis.eol import eol_note
11
+ from pipeline_analysis.models import SECRET_LITERAL, PipelineFinding, redact_line
12
+
13
+ SECRET_NAME = re.compile(r"(PASS(WORD)?|SECRET|TOKEN|API[_-]?KEY|PRIVATE[_-]?KEY|CREDENTIAL|ACCESS[_-]?KEY)", re.I)
14
+ PIPE_TO_SHELL = re.compile(r"(curl|wget)\b[^|;&\n]*\|\s*(sudo\s+)?(ba|z|da)?sh\b", re.I)
15
+ INSECURE = re.compile(r"(--no-check-certificate|--insecure|\bcurl\b[^\n]*\s-k\b|NODE_TLS_REJECT_UNAUTHORIZED\s*=\s*0|GIT_SSL_NO_VERIFY\s*=\s*(1|true)|strict-ssl\s+false)", re.I)
16
+ SENSITIVE_COPY = re.compile(r"(^|/)(\.env(\..+)?|id_rsa|id_ed25519|.*\.pem|.*\.p12|\.npmrc|\.pypirc|credentials|\.aws|\.ssh)(/|$)", re.I)
17
+ TRUSTED_REGISTRIES = ("mcr.microsoft.com", "gcr.io", "registry.k8s.io", "quay.io", "public.ecr.aws", "ghcr.io", "cgr.dev", "docker.io", "index.docker.io", "registry-1.docker.io")
18
+ SENSITIVE_HINT = ("secret", "password", "token", "key")
19
+
20
+
21
+ @dataclass
22
+ class Instr:
23
+ line: int
24
+ op: str
25
+ args: str
26
+ stage: int
27
+
28
+
29
+ def parse_dockerfile(text: str) -> list[Instr]:
30
+ """Instructions with line numbers (continuations joined, comments dropped, stage index assigned on FROM)."""
31
+ out: list[Instr] = []
32
+ stage, buf, start = -1, "", 0
33
+ for i, raw in enumerate(text.splitlines(), 1):
34
+ line = raw.rstrip()
35
+ if not buf and (not line.strip() or line.lstrip().startswith("#")):
36
+ continue
37
+ if line.lstrip().startswith("#") and buf:
38
+ continue
39
+ if not buf:
40
+ start = i
41
+ if line.endswith("\\"):
42
+ buf += line[:-1] + " "
43
+ continue
44
+ buf += line
45
+ m = re.match(r"^\s*([A-Za-z]+)\s*(.*)$", buf)
46
+ buf_text, buf = buf, ""
47
+ if not m:
48
+ continue
49
+ op, args = m.group(1).upper(), m.group(2).strip()
50
+ if op == "FROM":
51
+ stage += 1
52
+ out.append(Instr(start, op, args, max(stage, 0)))
53
+ return out
54
+
55
+
56
+ def split_image(ref: str) -> tuple[str, Optional[str], Optional[str]]:
57
+ """image reference -> (name, tag, digest)."""
58
+ digest = None
59
+ if "@" in ref:
60
+ ref, digest = ref.split("@", 1)
61
+ tag = None
62
+ last = ref.rsplit("/", 1)[-1]
63
+ if ":" in last:
64
+ ref, tag = ref.rsplit(":", 1)
65
+ return ref, tag, digest
66
+
67
+
68
+ def classify_image(name: str) -> str:
69
+ """official | verified-registry | community | unknown-registry (heuristic by registry host / namespace)."""
70
+ parts = name.split("/")
71
+ if "." in parts[0] or ":" in parts[0] or parts[0] == "localhost":
72
+ host = parts[0]
73
+ if host in ("docker.io", "index.docker.io", "registry-1.docker.io"):
74
+ parts = parts[1:]
75
+ elif host in TRUSTED_REGISTRIES:
76
+ return "verified-registry"
77
+ else:
78
+ return "unknown-registry"
79
+ if len(parts) == 1 or (len(parts) == 2 and parts[0] == "library"):
80
+ return "official"
81
+ return "community"
82
+
83
+
84
+ def _f(rule, title, sev, file, line, snippet, subject, why, fix, strength="high", refs=None, **extra) -> PipelineFinding:
85
+ return PipelineFinding(rule_id=rule, category="container", ecosystem="Docker", title=title, severity=sev, file=file, line=line, snippet=redact_line(snippet.strip())[:200],
86
+ subject=subject, why=why, remediation=fix, evidence_strength=strength, references=refs or [], extra=extra)
87
+
88
+
89
+ def analyze_dockerfile(text: str, path: str) -> tuple[list[PipelineFinding], list[dict]]:
90
+ """Return (findings, images). ``images`` lists every FROM with parsed name/tag/digest for the SBOM."""
91
+ ins = parse_dockerfile(text)
92
+ findings: list[PipelineFinding] = []
93
+ images: list[dict] = []
94
+ stage_names: set[str] = set()
95
+ last_stage = max((i.stage for i in ins), default=0)
96
+ user_by_stage: dict[int, str] = {}
97
+ for i in ins:
98
+ if i.op == "FROM":
99
+ a = re.sub(r"--platform=\S+\s*", "", i.args)
100
+ m = re.match(r"^(\S+)(?:\s+[Aa][Ss]\s+(\S+))?", a)
101
+ if not m:
102
+ continue
103
+ ref, alias = m.group(1), m.group(2)
104
+ if alias:
105
+ stage_names.add(alias.lower())
106
+ if ref.lower() in stage_names or ref.lower() == "scratch" or "$" in ref:
107
+ continue
108
+ name, tag, digest = split_image(ref)
109
+ kind = classify_image(name)
110
+ images.append({"ref": ref, "name": name, "tag": tag, "digest": digest, "kind": kind, "file": path, "line": i.line, "stage": i.stage, "final": False})
111
+ if not digest and (tag in (None, "latest")):
112
+ findings.append(_f("DF001", "Base image is not pinned to a version (uses 'latest' or no tag)", "HIGH", path, i.line, f"FROM {ref}", ref,
113
+ "A floating tag changes silently; a rebuild can pull different (possibly compromised or incompatible) content.",
114
+ "Pin a specific version tag and, for reproducibility, its sha256 digest.", refs=["https://docs.docker.com/build/building/best-practices/#pin-base-image-versions"]))
115
+ elif not digest:
116
+ findings.append(_f("DF002", "Base image tag is not pinned by digest", "LOW", path, i.line, f"FROM {ref}", ref,
117
+ "Tags are mutable: the same tag can later point to different content (tag re-push or registry compromise).",
118
+ f"Pin by digest: FROM {name}:{tag}@sha256:<digest>."))
119
+ if kind == "unknown-registry":
120
+ findings.append(_f("DF014", "Base image comes from an unrecognised registry", "MEDIUM", path, i.line, f"FROM {ref}", ref,
121
+ "Images from registries outside the well-known set have no established provenance or review process.",
122
+ "Use an official/verified image or mirror the image into a registry you control and verify its signature.", strength="medium"))
123
+ elif kind == "community":
124
+ findings.append(_f("DF015", "Base image is a community (non-official) image", "LOW", path, i.line, f"FROM {ref}", ref,
125
+ "Community images on Docker Hub are maintained by individuals; contents and update cadence are not vetted by Docker.",
126
+ "Prefer an official or verified-publisher image, or build from an official base.", strength="medium"))
127
+ note = eol_note(name, tag)
128
+ if note:
129
+ findings.append(_f("DF012", "Base image is an end-of-life version", "MEDIUM", path, i.line, f"FROM {ref}", ref, note + ". It no longer receives security fixes.",
130
+ "Move to a currently supported release line.", strength="medium"))
131
+ elif i.op == "USER":
132
+ user_by_stage[i.stage] = i.args.split(":")[0].strip().lower()
133
+ elif i.op == "ADD":
134
+ if re.match(r"^(--\S+\s+)*https?://", i.args):
135
+ findings.append(_f("DF004", "ADD downloads a remote file at build time", "HIGH", path, i.line, f"ADD {i.args}", i.args.split()[-2] if len(i.args.split()) > 1 else i.args,
136
+ "ADD <url> fetches unverified content with no checksum; the file can change between builds.",
137
+ "Use curl/wget with a pinned URL and verify a SHA-256 checksum, or COPY a vendored file."))
138
+ elif i.op in ("ENV", "ARG"):
139
+ for m in re.finditer(r"([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(\"[^\"]*\"|'[^']*'|\S+)", i.args):
140
+ nm, val = m.group(1), m.group(2).strip("\"'")
141
+ if (SECRET_NAME.search(nm) and val and not val.startswith("$") and val.lower() not in ("changeme", "")) or SECRET_LITERAL.search(val):
142
+ findings.append(_f("DF006", "Credential-like value is baked into the image", "HIGH", path, i.line, f"{i.op} {nm}=[REDACTED]", nm,
143
+ "Values in ENV/ARG are stored in image layers and visible to anyone who can pull the image.",
144
+ "Inject secrets at runtime (orchestrator secrets) or use BuildKit `--mount=type=secret`; rotate any value already committed."))
145
+ elif i.op in ("COPY", "ADD"):
146
+ pass
147
+ if i.op == "RUN":
148
+ if PIPE_TO_SHELL.search(i.args):
149
+ findings.append(_f("DF005", "Remote script is piped straight into a shell", "HIGH", path, i.line, f"RUN {i.args}", i.args[:80],
150
+ "Executes whatever the server returns at build time with no integrity check (classic supply-chain injection point).",
151
+ "Download to a file, verify a pinned checksum/signature, then execute."))
152
+ if INSECURE.search(i.args):
153
+ findings.append(_f("DF007", "TLS verification is disabled", "MEDIUM", path, i.line, f"RUN {i.args}", i.args[:80],
154
+ "Disabling certificate checks allows man-in-the-middle tampering of downloaded artifacts.", "Remove the insecure flag; fix the certificate chain instead."))
155
+ if re.search(r"chmod\s+(-R\s+)?0?777", i.args):
156
+ findings.append(_f("DF010", "World-writable permissions (chmod 777)", "MEDIUM", path, i.line, f"RUN {i.args}", "chmod 777", "Any process in the container can modify these files.", "Grant the minimum required permissions."))
157
+ if re.search(r"\bnpm\s+install\b(?!\s+-g)", i.args) and "npm ci" not in i.args:
158
+ findings.append(_f("DF008", "`npm install` used in container build instead of `npm ci`", "LOW", path, i.line, f"RUN {i.args}", "npm install",
159
+ "`npm install` in container builds may write to or re-evaluate package-lock.json if manifests differ; `npm ci` enforces strict, reproducible, read-only installation from the lockfile.",
160
+ "Use `npm ci` (exact lockfile install) for deterministic container builds.", strength="medium"))
161
+ if re.search(r"\bpip3?\s+install\b", i.args) and "--require-hashes" not in i.args and re.search(r"pip3?\s+install\s+(?!-r|--upgrade pip|-U pip)[A-Za-z]", i.args):
162
+ findings.append(_f("DF009", "Python packages installed without pinned versions or hashes", "LOW", path, i.line, f"RUN {i.args}", "pip install",
163
+ "Unpinned installs resolve to whatever is newest at build time.", "Pin versions (and `--require-hashes`) via a requirements/constraints file.", strength="medium"))
164
+ if i.op in ("COPY", "ADD"):
165
+ for tok in i.args.split():
166
+ if not tok.startswith("-") and SENSITIVE_COPY.search(tok.strip("\"'")):
167
+ findings.append(_f("DF011", "Sensitive-looking file is copied into the image", "HIGH", path, i.line, f"{i.op} {i.args}", tok,
168
+ "Keys, .env, .npmrc and credential files copied into a layer are recoverable by anyone with the image.",
169
+ "Exclude via .dockerignore and use build secrets instead.", strength="medium"))
170
+ break
171
+ # final stage should not run as root
172
+ if images:
173
+ images[-1]["final"] = True
174
+ final_user = user_by_stage.get(last_stage)
175
+ if ins and (final_user is None or final_user in ("root", "0")):
176
+ findings.append(_f("DF003", "Container runs as root", "MEDIUM", path, 0, "(no non-root USER in the final stage)" if final_user is None else "USER root", "USER",
177
+ "A compromised process inherits root inside the container, which eases breakout and tampering.", "Add a dedicated unprivileged `USER` before the entrypoint.",
178
+ refs=["https://docs.docker.com/build/building/best-practices/#user"]))
179
+ for i in ins: # secret literals anywhere in the file
180
+ if SECRET_LITERAL.search(i.args) and not any(f.rule_id == "DF006" and f.line == i.line for f in findings):
181
+ findings.append(_f("SEC001", "A credential appears to be committed in this file", "CRITICAL", path, i.line, f"{i.op} {i.args}", "credential",
182
+ "A live-looking token/key is stored in the repository.", "Revoke and rotate it now; move it to a secret store."))
183
+ return findings, images
184
+
185
+
186
+ def analyze_compose(text: str, path: str) -> tuple[list[PipelineFinding], list[dict]]:
187
+ findings: list[PipelineFinding] = []
188
+ images: list[dict] = []
189
+ try:
190
+ data = yaml.safe_load(text) or {}
191
+ except Exception:
192
+ return findings, images
193
+ services = (data.get("services") if isinstance(data, dict) else None) or {}
194
+ lines = text.splitlines()
195
+
196
+ def line_of(needle: str) -> int:
197
+ for n, l in enumerate(lines, 1):
198
+ if needle in l:
199
+ return n
200
+ return 0
201
+
202
+ for name, svc in services.items():
203
+ if not isinstance(svc, dict):
204
+ continue
205
+ img = svc.get("image")
206
+ if isinstance(img, str) and "$" not in img:
207
+ nm, tag, digest = split_image(img)
208
+ images.append({"ref": img, "name": nm, "tag": tag, "digest": digest, "kind": classify_image(nm), "file": path, "line": line_of(img), "stage": 0, "final": True, "service": name})
209
+ if not digest and tag in (None, "latest"):
210
+ findings.append(_f("DC001", f"Service '{name}' uses an unpinned image", "MEDIUM", path, line_of(img), f"image: {img}", img,
211
+ "A floating tag changes silently between deployments.", "Pin a version tag and digest."))
212
+ note = eol_note(nm, tag)
213
+ if note:
214
+ findings.append(_f("DF012", f"Service '{name}' uses an end-of-life image", "MEDIUM", path, line_of(img), f"image: {img}", img, note + ".", "Move to a supported release line.", strength="medium"))
215
+ if svc.get("privileged") is True:
216
+ findings.append(_f("DC002", f"Service '{name}' runs privileged", "HIGH", path, line_of("privileged"), "privileged: true", name,
217
+ "A privileged container has nearly the full capabilities of the host.", "Drop `privileged`; add only the specific capabilities needed."))
218
+ if str(svc.get("network_mode", "")).lower() == "host":
219
+ findings.append(_f("DC003", f"Service '{name}' uses the host network", "MEDIUM", path, line_of("network_mode"), "network_mode: host", name,
220
+ "Removes network isolation between the container and the host.", "Use a user-defined bridge network and publish only needed ports."))
221
+ vols = [str(v) for v in svc.get("volumes") or []]
222
+ if any("docker.sock" in v for v in vols):
223
+ findings.append(_f("DC004", f"Service '{name}' mounts the Docker socket", "HIGH", path, line_of("docker.sock"), "volumes: /var/run/docker.sock", name,
224
+ "Access to the Docker socket is equivalent to root on the host.", "Avoid it; use a socket proxy with a restricted API if unavoidable."))
225
+ caps = [str(c).upper() for c in svc.get("cap_add") or []]
226
+ if "ALL" in caps or "SYS_ADMIN" in caps:
227
+ findings.append(_f("DC005", f"Service '{name}' adds dangerous capabilities", "HIGH", path, line_of("cap_add"), f"cap_add: {', '.join(caps)}", name,
228
+ "SYS_ADMIN/ALL capabilities allow many container-escape techniques.", "Add only the minimal capability set."))
229
+ env = svc.get("environment")
230
+ pairs = list(env.items()) if isinstance(env, dict) else [str(e).split("=", 1) for e in (env or []) if "=" in str(e)]
231
+ for p in pairs:
232
+ if len(p) == 2 and p[1] not in (None, "") and SECRET_NAME.search(str(p[0])) and not str(p[1]).startswith("$"):
233
+ findings.append(_f("DC006", f"Service '{name}' has a hard-coded credential-like environment value", "MEDIUM", path, line_of(str(p[0])), f"{p[0]}=[REDACTED]", str(p[0]),
234
+ "Credentials in compose files end up in version control.", "Use `env_file` excluded from Git or Docker secrets.", strength="medium"))
235
+ return findings, images
@@ -0,0 +1,62 @@
1
+ """Known end-of-life base-image lines. A small, explicit table (vendor lifecycle pages), NOT a live feed: it is dated and the finding says so.
2
+
3
+ ``AS_OF`` is the date the table was last reviewed. A tag is flagged only when its version is at or below the listed last-EOL value.
4
+ """
5
+ from __future__ import annotations
6
+
7
+ import re
8
+ from typing import Optional
9
+
10
+ AS_OF = "2026-11"
11
+
12
+ # image (official name) -> (numeric-version regex on the tag, last EOL major/minor tuple, human note)
13
+ _LINES = {
14
+ "node": (r"^(\d+)", (20,), "Node.js 20 and older are end-of-life (even-numbered LTS lines end 30 months after release)"),
15
+ "python": (r"^(\d+)\.(\d+)", (3, 10), "Python 3.10 and older are end-of-life"),
16
+ "ubuntu": (r"^(\d+)\.(\d+)", (20, 4), "Ubuntu 20.04 and older have left standard support"),
17
+ "debian": (None, None, "Debian 11 (bullseye) and older"),
18
+ "alpine": (r"^(\d+)\.(\d+)", (3, 19), "Alpine 3.19 and older are unsupported"),
19
+ "centos": (r"^(\d+)", (8,), "CentOS 8 and older are end-of-life (CentOS Stream is the successor)"),
20
+ "openjdk": (r"^(\d+)", (16,), "non-LTS/old OpenJDK images are deprecated (use eclipse-temurin)"),
21
+ "php": (r"^(\d+)\.(\d+)", (8, 1), "PHP 8.1 and older are end-of-life"),
22
+ "ruby": (r"^(\d+)\.(\d+)", (3, 1), "Ruby 3.1 and older are end-of-life"),
23
+ "golang": (r"^(\d+)\.(\d+)", (1, 23), "Go releases older than the two latest are unsupported"),
24
+ "mysql": (r"^(\d+)\.(\d+)", (5, 7), "MySQL 5.7 and older are end-of-life"),
25
+ "postgres": (r"^(\d+)", (13,), "PostgreSQL 13 and older are end-of-life"),
26
+ "mongo": (r"^(\d+)\.(\d+)", (5, 0), "MongoDB 5.0 and older are end-of-life"),
27
+ "redis": (r"^(\d+)\.(\d+)", (6, 2), "Redis 6.2 and older are end-of-life"),
28
+ "nginx": (r"^(\d+)\.(\d+)", (1, 24), "old nginx lines are unsupported"),
29
+ }
30
+ _DEBIAN_EOL = {"buster", "bullseye", "stretch", "jessie", "wheezy"}
31
+
32
+
33
+ def eol_note(image: str, tag: Optional[str]) -> Optional[str]:
34
+ """Return a human note if ``image:tag`` is a known end-of-life line, else None. Unknown images/tags are never flagged."""
35
+ base = image.lower()
36
+ for pre in ("docker.io/", "index.docker.io/", "registry-1.docker.io/"):
37
+ if base.startswith(pre):
38
+ base = base[len(pre):]
39
+ if base.startswith("library/"):
40
+ base = base[len("library/"):]
41
+ if "/" in base: # namespaced / third-party registry image: the official-image lifecycle table does not apply
42
+ return None
43
+ name = base
44
+ if not tag or tag in ("latest",):
45
+ return None
46
+ t = tag.lower()
47
+ if name == "debian":
48
+ if any(c in t for c in _DEBIAN_EOL):
49
+ return _LINES["debian"][2]
50
+ m = re.match(r"^(\d+)", t)
51
+ return _LINES["debian"][2] if m and int(m.group(1)) <= 11 else None
52
+ spec = _LINES.get(name)
53
+ if not spec or not spec[0]:
54
+ return None
55
+ m = re.match(spec[0], t)
56
+ if not m:
57
+ return None
58
+ try:
59
+ got = tuple(int(x) for x in m.groups())
60
+ except ValueError:
61
+ return None
62
+ return f"{spec[2]} (lifecycle table reviewed {AS_OF})" if got <= spec[1] else None