local-triage 0.0.0-stage → 0.10.0-dev.32
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.
- package/LICENSE +21 -0
- package/README.md +90 -2
- package/THIRD-PARTY-NOTICES.md +48 -0
- package/app/__init__.py +3 -0
- package/app/affiliation.py +137 -0
- package/app/ask.py +300 -0
- package/app/build_info.py +98 -0
- package/app/capec.py +168 -0
- package/app/capec_view.py +27 -0
- package/app/codecmp.py +59 -0
- package/app/config.py +411 -0
- package/app/context.py +1451 -0
- package/app/cvss.py +357 -0
- package/app/db.py +6234 -0
- package/app/defect.py +670 -0
- package/app/defect_check.py +323 -0
- package/app/defect_drafts.py +612 -0
- package/app/defect_dto.py +149 -0
- package/app/defect_fields.py +248 -0
- package/app/defect_form.py +124 -0
- package/app/defect_links.py +107 -0
- package/app/defect_local_text.py +103 -0
- package/app/defect_references.py +164 -0
- package/app/defect_where.py +147 -0
- package/app/ecosystem.py +51 -0
- package/app/executors.py +660 -0
- package/app/feeds.py +1231 -0
- package/app/guard.py +164 -0
- package/app/hub_block_builder.py +200 -0
- package/app/hub_block_version.py +220 -0
- package/app/hub_defects.py +4469 -0
- package/app/hub_effects.py +421 -0
- package/app/hub_entity_versions.py +108 -0
- package/app/hub_import.py +2054 -0
- package/app/hub_onboarding.py +114 -0
- package/app/hub_ops.py +330 -0
- package/app/hub_pull.py +1195 -0
- package/app/hub_state.py +255 -0
- package/app/hub_status.py +237 -0
- package/app/hub_sync.py +619 -0
- package/app/hub_sync_api.py +241 -0
- package/app/hub_sync_compare.py +1054 -0
- package/app/hub_sync_contract.py +75 -0
- package/app/hub_template_model.py +74 -0
- package/app/hub_text_scale.py +159 -0
- package/app/journal.py +250 -0
- package/app/llm.py +850 -0
- package/app/llm_chat.py +596 -0
- package/app/llm_http.py +319 -0
- package/app/llm_messages.py +401 -0
- package/app/llm_net.py +764 -0
- package/app/llm_ollama.py +571 -0
- package/app/lockfile.py +505 -0
- package/app/logsafe.py +54 -0
- package/app/main.py +367 -0
- package/app/mask_display.py +132 -0
- package/app/masking.py +814 -0
- package/app/metrics.py +194 -0
- package/app/model_traffic.py +519 -0
- package/app/models.py +483 -0
- package/app/navigation.py +121 -0
- package/app/osv.py +279 -0
- package/app/package_identity.py +189 -0
- package/app/package_transition.py +824 -0
- package/app/profile_gate.py +71 -0
- package/app/prompts.py +1108 -0
- package/app/provider_keys.py +189 -0
- package/app/providers.py +511 -0
- package/app/routes/__init__.py +10 -0
- package/app/routes/api.py +153 -0
- package/app/routes/capec.py +186 -0
- package/app/routes/common.py +407 -0
- package/app/routes/components.py +1499 -0
- package/app/routes/cwe.py +168 -0
- package/app/routes/decision_selected.py +153 -0
- package/app/routes/defect_add.py +223 -0
- package/app/routes/defect_card_routes.py +363 -0
- package/app/routes/defect_selected.py +342 -0
- package/app/routes/feeds.py +155 -0
- package/app/routes/findings.py +2736 -0
- package/app/routes/hub.py +402 -0
- package/app/routes/hub_bulk.py +288 -0
- package/app/routes/hub_defect_routes.py +1945 -0
- package/app/routes/hub_status_routes.py +1132 -0
- package/app/routes/hub_sync_routes.py +463 -0
- package/app/routes/journal.py +132 -0
- package/app/routes/projects.py +1601 -0
- package/app/routes/providers.py +336 -0
- package/app/routes/references.py +26 -0
- package/app/routes/runs.py +219 -0
- package/app/routes/sca.py +2722 -0
- package/app/routes/settings.py +163 -0
- package/app/run_errors.py +151 -0
- package/app/sca.py +1662 -0
- package/app/sca_contract.py +1289 -0
- package/app/sca_research.py +1089 -0
- package/app/sca_research_net.py +1007 -0
- package/app/sca_text.py +965 -0
- package/app/serve.py +70 -0
- package/app/settings_store.py +262 -0
- package/app/static/app.css +2802 -0
- package/app/static/app.js +3772 -0
- package/app/static/capec-license.txt +9 -0
- package/app/static/favicon.svg +1 -0
- package/app/static/fonts/Golos-Text_DemiBold.woff2 +0 -0
- package/app/static/fonts/Golos-Text_Regular.woff2 +0 -0
- package/app/static/fonts/OFL.txt +90 -0
- package/app/static/navigation.js +234 -0
- package/app/static/observability.js +121 -0
- package/app/static/theme.js +49 -0
- package/app/storage/__init__.py +16 -0
- package/app/storage/local_state.py +246 -0
- package/app/storage/migrate.py +110 -0
- package/app/storage/migrations/postgresql/0001_baseline.sql +896 -0
- package/app/storage/migrations/postgresql/0002_feeds_and_secrets.sql +55 -0
- package/app/storage/migrations/postgresql/0003_project_mask_display.sql +5 -0
- package/app/storage/migrations/postgresql/0004_package_identity.sql +36 -0
- package/app/storage/postgresql.py +573 -0
- package/app/storage/schema.py +619 -0
- package/app/storage/sql.py +57 -0
- package/app/storage/tools.py +254 -0
- package/app/telemetry.py +307 -0
- package/app/templates/base.html +91 -0
- package/app/templates/capec/context.html +3 -0
- package/app/templates/capec/detail.html +27 -0
- package/app/templates/capec/index.html +128 -0
- package/app/templates/components/_archive.html +11 -0
- package/app/templates/components/archived.html +19 -0
- package/app/templates/components/batch.html +35 -0
- package/app/templates/components/detail.html +332 -0
- package/app/templates/components/index.html +338 -0
- package/app/templates/components/research_preview.html +80 -0
- package/app/templates/components/research_run.html +54 -0
- package/app/templates/cwe/bdu.html +56 -0
- package/app/templates/cwe/detail.html +233 -0
- package/app/templates/cwe/index.html +97 -0
- package/app/templates/error.html +8 -0
- package/app/templates/feeds/index.html +65 -0
- package/app/templates/findings/card.html +639 -0
- package/app/templates/findings/decision_selected.html +41 -0
- package/app/templates/findings/defect_add.html +46 -0
- package/app/templates/findings/defect_selected.html +47 -0
- package/app/templates/findings/list.html +153 -0
- package/app/templates/findings/send_selected.html +53 -0
- package/app/templates/findings/trace.html +72 -0
- package/app/templates/journal/detail.html +19 -0
- package/app/templates/journal/index.html +19 -0
- package/app/templates/macros.html +440 -0
- package/app/templates/navigation-fields.html +1 -0
- package/app/templates/navigation.html +11 -0
- package/app/templates/projects/_identity_summary.html +42 -0
- package/app/templates/projects/defect_card.html +153 -0
- package/app/templates/projects/defect_create_preview.html +17 -0
- package/app/templates/projects/defect_fields_diff.html +6 -0
- package/app/templates/projects/defect_fields_form.html +40 -0
- package/app/templates/projects/defect_references.html +17 -0
- package/app/templates/projects/defect_sync_preview.html +28 -0
- package/app/templates/projects/defect_update_actions.html +6 -0
- package/app/templates/projects/defect_update_preview.html +24 -0
- package/app/templates/projects/defects.html +126 -0
- package/app/templates/projects/delete.html +31 -0
- package/app/templates/projects/external.html +61 -0
- package/app/templates/projects/folders.html +64 -0
- package/app/templates/projects/hub_accepted.html +10 -0
- package/app/templates/projects/hub_assignment.html +50 -0
- package/app/templates/projects/hub_pending.html +20 -0
- package/app/templates/projects/hub_pending_list.html +17 -0
- package/app/templates/projects/hub_state_note.html +23 -0
- package/app/templates/projects/hub_step_note.html +5 -0
- package/app/templates/projects/hub_sync.html +105 -0
- package/app/templates/projects/hub_sync_confirm.html +32 -0
- package/app/templates/projects/hub_sync_worker.html +5 -0
- package/app/templates/projects/hub_text_rules.html +64 -0
- package/app/templates/projects/identity_report.html +74 -0
- package/app/templates/projects/list.html +90 -0
- package/app/templates/projects/project.html +433 -0
- package/app/templates/reference-missing.html +14 -0
- package/app/templates/runs/run.html +166 -0
- package/app/templates/sca/card.html +476 -0
- package/app/templates/sca/index.html +321 -0
- package/app/templates/settings/hub_url.html +31 -0
- package/app/templates/settings/index.html +216 -0
- package/app/templates/settings/provider.html +229 -0
- package/app/templates/settings/providers.html +37 -0
- package/app/templates/worklists.html +52 -0
- package/app/textsafe.py +117 -0
- package/app/timing.py +245 -0
- package/app/triage.py +1743 -0
- package/app/view.py +430 -0
- package/app/worklists.py +204 -0
- package/examples/demo/demo-hub-report-v2.xlsx +0 -0
- package/examples/demo/demo-hub-report.xlsx +0 -0
- package/examples/demo/repos/billing-core/pom.xml +30 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/Invoice.java +9 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/InvoiceRepository.java +51 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/InvoiceStatus.java +11 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/config/DatabaseSettings.java +18 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/payment/PaymentTokenService.java +35 -0
- package/examples/demo/repos/billing-core/src/main/java/org/example/billing/web/InvoiceExportController.java +57 -0
- package/examples/demo/repos/catalog-api/catalog_api/__init__.py +1 -0
- package/examples/demo/repos/catalog-api/catalog_api/products.py +24 -0
- package/examples/demo/repos/catalog-api/catalog_api/tasks.py +24 -0
- package/examples/demo/repos/catalog-api/catalog_api/views.py +17 -0
- package/examples/demo/repos/catalog-api/requirements.txt +3 -0
- package/npm/build.json +5 -0
- package/npm/cli.js +346 -0
- package/npm/files.manifest +224 -0
- package/npm/lib/binding.js +64 -0
- package/npm/lib/cluster.js +330 -0
- package/npm/lib/env.js +88 -0
- package/npm/lib/fsx.js +125 -0
- package/npm/lib/http.js +53 -0
- package/npm/lib/metrics.js +73 -0
- package/npm/lib/paths.js +150 -0
- package/npm/lib/pg.js +351 -0
- package/npm/lib/proc.js +101 -0
- package/npm/lib/python.js +133 -0
- package/npm/lib/stand.js +46 -0
- package/npm/lib/supervisor.js +1141 -0
- package/npm/lib/version.js +21 -0
- package/npm/requirements.txt +476 -0
- package/npm-shrinkwrap.json +111 -0
- package/package.json +37 -4
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"""Адаптер замеров Hub; полнота списков проверяется в каждом обходе."""
|
|
2
|
+
|
|
3
|
+
from dataclasses import asdict, dataclass
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
|
+
from urllib.parse import urlencode
|
|
6
|
+
|
|
7
|
+
from app.hub_sync_contract import SYNC_PROTOCOL
|
|
8
|
+
|
|
9
|
+
DETAIL_PATHS = {"SAST": "sast", "SCA_S": "sca/security", "SCA_L": "sca/compliance", "DAST": "dast"}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@dataclass(frozen=True)
|
|
13
|
+
class Adapter:
|
|
14
|
+
version: str = "hub-sync/1"
|
|
15
|
+
issue_sort: int | None = None
|
|
16
|
+
first_page: int | None = None
|
|
17
|
+
serialization: str | None = None
|
|
18
|
+
all_branches: bool = False
|
|
19
|
+
manual_absent: tuple[int, str] | None = None
|
|
20
|
+
risk_absent: tuple[int, str] | None = None
|
|
21
|
+
manual_scope: bool = False
|
|
22
|
+
evidence: str = ""
|
|
23
|
+
issue_size: int = 100
|
|
24
|
+
defect_size: int = 50
|
|
25
|
+
manual_empty: bool = False
|
|
26
|
+
|
|
27
|
+
def passport(self):
|
|
28
|
+
return asdict(self)
|
|
29
|
+
|
|
30
|
+
def absent_response(self, part, result):
|
|
31
|
+
"""Только измеренные формы отсутствия, отдельно для каждого вида ответа."""
|
|
32
|
+
text = result.get("body_text")
|
|
33
|
+
if not isinstance(text, str):
|
|
34
|
+
return False
|
|
35
|
+
if part == "manual" and self.manual_empty and result.get("status") == 200 and not text.strip():
|
|
36
|
+
return True
|
|
37
|
+
absent = self.manual_absent if part == "manual" else self.risk_absent if part == "risk" else None
|
|
38
|
+
return bool(absent and result.get("status") == absent[0]
|
|
39
|
+
and (text == absent[1] or (absent[1] == "null" and text.strip() == "null")))
|
|
40
|
+
|
|
41
|
+
def require(self):
|
|
42
|
+
if (type(self.issue_sort) is not int or type(self.first_page) is not int
|
|
43
|
+
or self.serialization != "flat" or not self.evidence
|
|
44
|
+
or self.manual_absent is None):
|
|
45
|
+
raise ValueError("Контракт полного чтения Hub ещё не подтверждён (ADR-0127 §12.1). "
|
|
46
|
+
"Параметры сортировки, веток и отсутствия решений требуют проверки.")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
ADAPTER = Adapter(version="hub-sync/3-observed-2026-10-30", issue_sort=0, first_page=0,
|
|
50
|
+
serialization="flat", manual_absent=(200, "null"), defect_size=100,
|
|
51
|
+
manual_empty=True, manual_scope=True,
|
|
52
|
+
evidence="Пустой ручной статус; запись без условия относится ко всей находке")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def request(path, **params):
|
|
56
|
+
return {"method": "GET", "path": path + ("?" + urlencode(params) if params else ""),
|
|
57
|
+
"body": None, "sync_protocol": SYNC_PROTOCOL}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def page(adapter, kind, app_id, index, size=None):
|
|
61
|
+
adapter.require()
|
|
62
|
+
if kind == "issue":
|
|
63
|
+
return request("/issue/v2", appIds=app_id, pageIndex=index, pageSize=size or adapter.issue_size,
|
|
64
|
+
sort=adapter.issue_sort, **({"ignoreBranchFilter": "true"} if adapter.all_branches else {}))
|
|
65
|
+
return request("/defects", appId=app_id, pageIndex=index, pageSize=size or adapter.defect_size)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def application_id(obj, kind):
|
|
69
|
+
actual = obj.get("appId")
|
|
70
|
+
if kind == "defect":
|
|
71
|
+
if actual is None and isinstance(obj.get("app"), dict):
|
|
72
|
+
actual = obj["app"].get("id")
|
|
73
|
+
elif isinstance(actual, dict):
|
|
74
|
+
actual = actual.get("id")
|
|
75
|
+
if isinstance(obj.get("app"), dict) and obj["app"].get("id") != actual:
|
|
76
|
+
raise ValueError("app и appId объекта противоречат друг другу.")
|
|
77
|
+
return actual
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def detail(kind, key, branch=None):
|
|
81
|
+
if kind == "defect":
|
|
82
|
+
return request(f"/defects/{key}")
|
|
83
|
+
issue_type, issue_id = key.split(":", 1)
|
|
84
|
+
return request(f"/issue/{DETAIL_PATHS[issue_type]}/{issue_id}",
|
|
85
|
+
**({"branch": branch} if branch is not None and issue_type != "DAST" else {}))
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def identifier(obj, app_id, kind):
|
|
89
|
+
if not isinstance(obj, dict) or type(obj.get("id")) is not int or not 0 < obj["id"] < 10**12:
|
|
90
|
+
raise ValueError("Объект без допустимого ID.")
|
|
91
|
+
actual = application_id(obj, kind)
|
|
92
|
+
if type(actual) is not int or actual != app_id:
|
|
93
|
+
raise ValueError("Объект другого приложения или без appId.")
|
|
94
|
+
if kind == "issue":
|
|
95
|
+
if not isinstance(obj.get("type"), str) or not obj["type"]:
|
|
96
|
+
raise ValueError("У находки не указан тип.")
|
|
97
|
+
return f"{obj['type']}:{obj['id']}"
|
|
98
|
+
return str(obj["id"])
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class ShortPage(ValueError):
|
|
102
|
+
def __init__(self, size):
|
|
103
|
+
super().__init__(f"Hub урезал промежуточную страницу до {size}; нужен обход с новым шагом.")
|
|
104
|
+
self.size = size
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def read_page(body, app_id, kind, previous_total, seen, size):
|
|
108
|
+
if not isinstance(body, dict) or not isinstance(body.get("filteredEntities"), list):
|
|
109
|
+
raise ValueError("В странице нет массива filteredEntities.")
|
|
110
|
+
total, objects = body.get("totalEntitiesCount"), body["filteredEntities"]
|
|
111
|
+
if type(total) is not int or total < 0 or (previous_total is not None and total != previous_total):
|
|
112
|
+
raise ValueError("Число объектов Hub изменилось или некорректно. Полнота обхода не установлена.")
|
|
113
|
+
keys = [identifier(obj, app_id, kind) for obj in objects]
|
|
114
|
+
if len(set(keys)) != len(keys):
|
|
115
|
+
raise ValueError("Повтор ключа внутри страницы.")
|
|
116
|
+
if len(seen) + len(objects) > total or len(objects) > size:
|
|
117
|
+
raise ValueError("Размер страницы не соответствует заявленному числу объектов.")
|
|
118
|
+
if len(seen) + len(objects) < total and len(objects) != size:
|
|
119
|
+
if objects:
|
|
120
|
+
raise ShortPage(len(objects))
|
|
121
|
+
raise ValueError("Неполная промежуточная страница: продолжение по индексу не подтверждено.")
|
|
122
|
+
if set(keys) & seen:
|
|
123
|
+
raise ValueError("Повтор ключа между страницами.")
|
|
124
|
+
return total, list(zip(keys, objects, strict=True))
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
def expired(value):
|
|
128
|
+
if value is None or value == "":
|
|
129
|
+
return False
|
|
130
|
+
try:
|
|
131
|
+
instant = (datetime.fromtimestamp(value / 1000, UTC) if type(value) is int
|
|
132
|
+
else datetime.fromisoformat(value.replace("Z", "+00:00")))
|
|
133
|
+
return instant.tzinfo is None or instant <= datetime.now(UTC)
|
|
134
|
+
except (TypeError, ValueError, AttributeError, OverflowError, OSError):
|
|
135
|
+
return True
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def composition_problems(detail):
|
|
139
|
+
"""Ни одна связь не теряется при преобразовании полного состава в множество."""
|
|
140
|
+
if not isinstance(detail, dict) or not isinstance(detail.get("linkedIssues"), list):
|
|
141
|
+
return ["В подробном дефекте отсутствует состав linkedIssues."]
|
|
142
|
+
seen = set()
|
|
143
|
+
for link in detail["linkedIssues"]:
|
|
144
|
+
if (not isinstance(link, dict) or type(link.get("id")) is not int
|
|
145
|
+
or not 0 < link["id"] < 10**12 or not isinstance(link.get("type"), str)
|
|
146
|
+
or link["type"] not in DETAIL_PATHS):
|
|
147
|
+
return ["Состав linkedIssues содержит связь без допустимого ID или типа."]
|
|
148
|
+
pair = (link["id"], link["type"])
|
|
149
|
+
if pair in seen:
|
|
150
|
+
return ["Состав linkedIssues содержит повтор одной связи."]
|
|
151
|
+
seen.add(pair)
|
|
152
|
+
return []
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
# Пометки Hub (dev15, план п. 1.2): сведения прочитаны полностью, но расходятся между собой. Находка принимается по
|
|
156
|
+
# проекции решения Hub (`hub_sync_compare.issue_values`: статус – подробный, основание – только из своей согласованной
|
|
157
|
+
# записи), пометка показывается у находки и не является отличием. Остальные проблемы – неполное чтение: объект не
|
|
158
|
+
# принимается до нового чтения (после принятия расхождений быть не должно).
|
|
159
|
+
HUB_NOTES = (
|
|
160
|
+
"Подробный статус и ручная запись противоречат друг другу.",
|
|
161
|
+
"Ручная запись относится к другой находке.",
|
|
162
|
+
"Применимость ручного решения к ветке или условию не установлена.",
|
|
163
|
+
"Срок ручного решения истёк или некорректен.",
|
|
164
|
+
"Основание ложного срабатывания отсутствует.",
|
|
165
|
+
"Сведения о принятом риске отсутствуют.",
|
|
166
|
+
"Риск не подтверждён как действующий для этой находки.",
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
# имена типа находки в записях Hub: в ручной записи (GET /issue/status) для SCA Hub пишет человеческое имя листа
|
|
171
|
+
# выгрузки, а не код типа из пути и списка: у ручных записей SCA
|
|
172
|
+
# «SCA Security» при ключе находки SCA_S, у SAST – «SAST». К записи риска (GET /issue/{type}/{id}/riskAcceptance)
|
|
173
|
+
# применяется та же точная таблица; её фактическая форма не наблюдалась.
|
|
174
|
+
# Сопоставление – только по этой таблице, без угадывания
|
|
175
|
+
ISSUE_TYPE_NAMES = {"SCA Security": "SCA_S", "SCA Compliance": "SCA_L"}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def same_issue_type(value, issue_type) -> bool:
|
|
179
|
+
"""Тип в записи Hub – тот же, что у находки: код типа (SAST, SCA_S, SCA_L, DAST) или его имя в записях Hub."""
|
|
180
|
+
text = str(value or "")
|
|
181
|
+
return text == issue_type or ISSUE_TYPE_NAMES.get(text) == issue_type
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def risk_valid(risk, key, app_id) -> bool:
|
|
185
|
+
"""Запись риска действует для этой находки этого приложения: ID и тип, приложение, активна, не удалена, без
|
|
186
|
+
условия, срок не истёк. Одна проверка для диагностики и для проекции решения Hub (ревью dev15, Codex круг 3)."""
|
|
187
|
+
if not isinstance(risk, dict) or not key or app_id is None:
|
|
188
|
+
return False
|
|
189
|
+
issue_type, issue_id = key.split(":", 1)
|
|
190
|
+
return (str(risk.get("issueId")) == str(issue_id) and same_issue_type(risk.get("issueType"), issue_type)
|
|
191
|
+
and risk.get("appId") == app_id and risk.get("isActive") is True and not risk.get("deleteTs")
|
|
192
|
+
and risk.get("isConditional") is False and not expired(risk.get("expiredAt")))
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def blocking(problems):
|
|
196
|
+
"""Проблемы неполного чтения – всё, кроме пометок Hub."""
|
|
197
|
+
return [p for p in problems if p not in HUB_NOTES]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def evidence_problems(hub, key, app_id, adapter):
|
|
201
|
+
"""Отдельные свидетельства не превращаются в составное решение без проверки."""
|
|
202
|
+
problems = []
|
|
203
|
+
issue_type, issue_id = key.split(":", 1)
|
|
204
|
+
brief, details = hub.get("brief", {}), hub.get("detail") or {}
|
|
205
|
+
manual, risk = hub.get("manual"), hub.get("risk")
|
|
206
|
+
if not isinstance(details, dict) or not isinstance(details.get("status"), str):
|
|
207
|
+
return ["Текущий подробный статус не получен."]
|
|
208
|
+
if brief.get("currentBranch") is not None and brief["currentBranch"] != details.get("currentBranch"):
|
|
209
|
+
problems.append("Ветка основного подробного ответа не совпала с currentBranch списка.")
|
|
210
|
+
if manual is not None:
|
|
211
|
+
if not isinstance(manual, dict):
|
|
212
|
+
return ["Ручная запись имеет неверный формат."]
|
|
213
|
+
if manual.get("issueId") != int(issue_id) or not same_issue_type(manual.get("issueType"), issue_type):
|
|
214
|
+
problems.append("Ручная запись относится к другой находке.")
|
|
215
|
+
if manual.get("status") != details["status"]:
|
|
216
|
+
problems.append("Подробный статус и ручная запись противоречат друг другу.")
|
|
217
|
+
if brief.get("issueChangeStatusInfoId") is not None and brief["issueChangeStatusInfoId"] != manual.get("id"):
|
|
218
|
+
problems.append("ID ручной записи изменился после чтения списка.")
|
|
219
|
+
if not adapter.manual_scope or any(manual.get(k) is not None for k in ("conditionalCategory", "branch", "isConditional")):
|
|
220
|
+
problems.append("Применимость ручного решения к ветке или условию не установлена.")
|
|
221
|
+
if expired(manual.get("expiredAt")):
|
|
222
|
+
problems.append("Срок ручного решения истёк или некорректен.")
|
|
223
|
+
elif details["status"] == "False Positive":
|
|
224
|
+
# ручная запись читается после подробностей всегда (hub_sync.consume_object): нет ключа – её чтение не
|
|
225
|
+
# завершилось (неполное чтение), null – Hub подтвердил, что записи нет (пометка Hub, ревью плана dev15)
|
|
226
|
+
problems.append("Основание ложного срабатывания отсутствует." if "manual" in hub
|
|
227
|
+
else "Ручная запись находки не прочитана.")
|
|
228
|
+
if any(isinstance(obj, dict) and obj.get("status") == "Accepted risk"
|
|
229
|
+
for name, obj in hub.items() if name in ("detail", "manual") or name.startswith("branch:")):
|
|
230
|
+
# как у ручной записи: ключа нет – не прочитано, null – Hub подтвердил отсутствие (пометка), иное – неверный
|
|
231
|
+
# формат (ревью dev15: мусорный ответ не должен проходить пометкой)
|
|
232
|
+
if "risk" not in hub:
|
|
233
|
+
problems.append("Сведения о принятом риске не прочитаны.")
|
|
234
|
+
elif risk is None:
|
|
235
|
+
problems.append("Сведения о принятом риске отсутствуют.")
|
|
236
|
+
elif not isinstance(risk, dict):
|
|
237
|
+
problems.append("Запись риска имеет неверный формат.")
|
|
238
|
+
elif not risk_valid(risk, key, app_id):
|
|
239
|
+
problems.append("Риск не подтверждён как действующий для этой находки.")
|
|
240
|
+
# Дополнительные ветки сохраняются отдельно; их статус не подменяет выбранную ветку.
|
|
241
|
+
return problems
|