@shiftleftpt/sbd-toe-mcp 0.6.2 → 0.7.0
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/assets/agent-guide.md +22 -19
- package/data/publish/algolia_entities_records_enriched.json +25370 -2
- package/data/publish/canonical_controls.json +1239 -0
- package/data/publish/canonical_requirements_s7.json +1859 -0
- package/data/publish/canonical_roles_s5.json +138 -0
- package/data/publish/lifecycle_user_stories.json +6558 -0
- package/data/publish/mitigated_threats.json +6945 -0
- package/data/publish/practice_assignments.json +16266 -0
- package/data/publish/sbdtoe-ontology.yaml +696 -0
- package/dist/backend/semantic-index-gateway.js +1 -1
- package/dist/index.js +276 -115
- package/dist/index.js.map +1 -1
- package/dist/resources/sbd-toe-resources.js +6 -1
- package/dist/resources/sbd-toe-resources.js.map +1 -1
- package/dist/tools/consult-security-requirements.d.ts +38 -0
- package/dist/tools/consult-security-requirements.js +115 -0
- package/dist/tools/consult-security-requirements.js.map +1 -0
- package/dist/tools/get-guide-by-role.d.ts +38 -0
- package/dist/tools/get-guide-by-role.js +109 -0
- package/dist/tools/get-guide-by-role.js.map +1 -0
- package/dist/tools/get-threat-landscape.d.ts +44 -0
- package/dist/tools/get-threat-landscape.js +116 -0
- package/dist/tools/get-threat-landscape.js.map +1 -0
- package/dist/tools/map-review-scope.js +5 -0
- package/dist/tools/map-review-scope.js.map +1 -1
- package/dist/tools/ontology-loader.d.ts +104 -0
- package/dist/tools/ontology-loader.js +206 -0
- package/dist/tools/ontology-loader.js.map +1 -0
- package/dist/tools/plan-repo-governance.d.ts +25 -38
- package/dist/tools/plan-repo-governance.js +71 -498
- package/dist/tools/plan-repo-governance.js.map +1 -1
- package/dist/tools/resolve-entities.d.ts +26 -0
- package/dist/tools/resolve-entities.js +143 -0
- package/dist/tools/resolve-entities.js.map +1 -0
- package/package.json +4 -1
- package/dist/tools/generate-document.d.ts +0 -22
- package/dist/tools/generate-document.js +0 -392
- package/dist/tools/generate-document.js.map +0 -1
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
# SbD-ToE Ontology v1.0
|
|
2
|
+
# Generated from real data: 130 requirements, 14 controls, 175 practices, 233 threats
|
|
3
|
+
# Escopo completo — 15 categorias de requisitos, 8 domínios de controlo
|
|
4
|
+
# Usado pelo OntologyEngine para resolução determinística de decisões de segurança
|
|
5
|
+
|
|
6
|
+
meta:
|
|
7
|
+
name: "SbD-ToE Security Ontology"
|
|
8
|
+
version: "1.0"
|
|
9
|
+
description: >
|
|
10
|
+
Ontologia computável do manual SbD-ToE. Transforma o manual num modelo de decisão:
|
|
11
|
+
dado um contexto de aplicação, resolve requisitos → controlos → práticas → regras → evidências.
|
|
12
|
+
data_sources:
|
|
13
|
+
requirements: "data/entities/canonical_requirements_s7.json"
|
|
14
|
+
controls: "data/entities/canonical_controls.json"
|
|
15
|
+
practices: "data/entities/practices.json"
|
|
16
|
+
threats: "data/entities/mitigated_threats.json"
|
|
17
|
+
artifacts: "data/entities/artifact_catalog.json"
|
|
18
|
+
phases: "data/entities/sdlc_phases_canonical_s6.json"
|
|
19
|
+
roles: "data/entities/canonical_roles_s5.json"
|
|
20
|
+
user_stories: "data/entities/lifecycle_user_stories.json"
|
|
21
|
+
assignments: "data/entities/practice_assignments.json"
|
|
22
|
+
control_links: "data/entities/control_links.json"
|
|
23
|
+
maturity: "data/entities/maturity_mappings.json"
|
|
24
|
+
policy_refs: "data/entities/policy_references.json"
|
|
25
|
+
proportionality: "data/entities/proportionality.json"
|
|
26
|
+
evidence_patterns: "data/entities/evidence_patterns.json" # extrai de: addon/10-validacao-requisitos.md (Cap02) + addon/05-validacao.md (Cap04)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
30
|
+
# ENTITIES
|
|
31
|
+
# Cada entidade mapeia para um ficheiro JSON + campo de ID
|
|
32
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
33
|
+
|
|
34
|
+
entities:
|
|
35
|
+
|
|
36
|
+
Application:
|
|
37
|
+
description: "Contexto de aplicação avaliada — não persiste, é input em runtime"
|
|
38
|
+
attributes:
|
|
39
|
+
- id: string
|
|
40
|
+
- name: string
|
|
41
|
+
- risk_level: enum[L1, L2, L3]
|
|
42
|
+
- exposure: enum[local, internal, authenticated, public]
|
|
43
|
+
- data_sensitivity: enum[low, personal, regulated, secrets]
|
|
44
|
+
- technologies: list[string]
|
|
45
|
+
- chapter_context: string # ex: logging, auth, api (filtro de ameaças)
|
|
46
|
+
- concerns: list[string] # ex: [logging, auth, api] — multi-domínio
|
|
47
|
+
- artifact_type: string # ex: http_endpoint, batch_job, cli, library
|
|
48
|
+
- deployment_context: string # ex: cloud, on-premise, hybrid, serverless
|
|
49
|
+
|
|
50
|
+
Requirement:
|
|
51
|
+
description: "Requisito de segurança extraído do manual SbD-ToE"
|
|
52
|
+
source_file: "data/entities/canonical_requirements_s7.json"
|
|
53
|
+
id_field: "requirement_id"
|
|
54
|
+
attributes:
|
|
55
|
+
- requirement_id: string # ex: AUT-001, LOG-003
|
|
56
|
+
- type: enum[base, architecture, iac]
|
|
57
|
+
- category: string # ex: AUT, LOG, ACC, VAL, ...
|
|
58
|
+
- domain: string # label semântico
|
|
59
|
+
- name: string
|
|
60
|
+
- applicable_levels: # quais níveis de risco exigem este req
|
|
61
|
+
L1: boolean
|
|
62
|
+
L2: boolean
|
|
63
|
+
L3: boolean
|
|
64
|
+
- source_chapter: integer # 2, 4, 8
|
|
65
|
+
- source_file: string
|
|
66
|
+
|
|
67
|
+
Control:
|
|
68
|
+
description: "Controlo operacional canónico — estratégia técnica de mitigação"
|
|
69
|
+
source_file: "data/entities/canonical_controls.json"
|
|
70
|
+
id_field: "control_id"
|
|
71
|
+
attributes:
|
|
72
|
+
- control_id: string # ex: CTRL-identity-...
|
|
73
|
+
- name: string
|
|
74
|
+
- domain: string # code_integrity | governance | identity | infrastructure | monitoring | secrets | supply_chain | testing
|
|
75
|
+
- control_type: enum[preventive, detective, corrective, governance]
|
|
76
|
+
- applicable_lifecycle_phases: list[string]
|
|
77
|
+
- artifact_types: list[string]
|
|
78
|
+
- source_practice_ids: list[string]
|
|
79
|
+
- abstraction_level: enum[technical, governance]
|
|
80
|
+
|
|
81
|
+
Threat:
|
|
82
|
+
description: "Ameaça de segurança mitigada pelo manual"
|
|
83
|
+
source_file: "data/entities/mitigated_threats.json"
|
|
84
|
+
id_field: "id"
|
|
85
|
+
attributes:
|
|
86
|
+
- id: string
|
|
87
|
+
- name: string
|
|
88
|
+
- category: string # STRIDE category quando disponível
|
|
89
|
+
- associated_controls: list[string]
|
|
90
|
+
- chapter_id: string
|
|
91
|
+
- cwe: string
|
|
92
|
+
- cvss_score: float
|
|
93
|
+
|
|
94
|
+
Artifact:
|
|
95
|
+
description: "Artefacto de segurança exigido ou produzido"
|
|
96
|
+
source_file: "data/entities/artifact_catalog.json"
|
|
97
|
+
id_field: "artifact_type_id"
|
|
98
|
+
attributes:
|
|
99
|
+
- artifact_type_id: string # ex: ART-access-review-...
|
|
100
|
+
- name: string
|
|
101
|
+
- category: string # governance_record | test_report | config | ...
|
|
102
|
+
- lifecycle_phases: list[string]
|
|
103
|
+
- produced_by_controls: list[string]
|
|
104
|
+
- validated_by_controls: list[string]
|
|
105
|
+
|
|
106
|
+
Practice:
|
|
107
|
+
description: "Prática operacional de segurança — o que FAZER"
|
|
108
|
+
source_file: "data/entities/practices.json"
|
|
109
|
+
id_field: "id"
|
|
110
|
+
attributes:
|
|
111
|
+
- id: string # ex: 06-desenvolvimento-seguro:code-review-seguro
|
|
112
|
+
- label: string
|
|
113
|
+
- chapter_id: string
|
|
114
|
+
|
|
115
|
+
UserStory:
|
|
116
|
+
description: "User story de ciclo de vida — liga práticas a roles + contextos"
|
|
117
|
+
source_file: "data/entities/lifecycle_user_stories.json"
|
|
118
|
+
id_field: "id"
|
|
119
|
+
attributes:
|
|
120
|
+
- id: string # ex: 06-desenvolvimento-seguro-us-03
|
|
121
|
+
- us_id: string
|
|
122
|
+
- title: string
|
|
123
|
+
- goal: string
|
|
124
|
+
- practice_id: string
|
|
125
|
+
- roles_normalized: list[string]
|
|
126
|
+
- chapter_id: string
|
|
127
|
+
- artifacts: list[string]
|
|
128
|
+
- checklist_items: list[string]
|
|
129
|
+
|
|
130
|
+
PracticeAssignment:
|
|
131
|
+
description: "Tarefa concreta: quem faz o quê, em que fase, com que nível de risco"
|
|
132
|
+
source_file: "data/entities/practice_assignments.json"
|
|
133
|
+
id_field: "id"
|
|
134
|
+
attributes:
|
|
135
|
+
- id: string
|
|
136
|
+
- practice_id: string
|
|
137
|
+
- action: string
|
|
138
|
+
- role: string
|
|
139
|
+
- phase: string
|
|
140
|
+
- risk_level: enum[L1, L2, L3]
|
|
141
|
+
- proportionality: string
|
|
142
|
+
- artifacts: list[string]
|
|
143
|
+
|
|
144
|
+
SDLCPhase:
|
|
145
|
+
description: "Fase canónica do ciclo de vida de desenvolvimento"
|
|
146
|
+
source_file: "data/entities/sdlc_phases_canonical_s6.json"
|
|
147
|
+
id_field: "phase_id"
|
|
148
|
+
attributes:
|
|
149
|
+
- phase_id: string # plan | design | develop | build | test | release | deploy | operate
|
|
150
|
+
- label: string
|
|
151
|
+
- aliases: list[string]
|
|
152
|
+
- manual_chapter: integer
|
|
153
|
+
|
|
154
|
+
Role:
|
|
155
|
+
description: "Papel/responsável na execução de práticas"
|
|
156
|
+
source_file: "data/entities/canonical_roles_s5.json"
|
|
157
|
+
id_field: "role_id"
|
|
158
|
+
attributes:
|
|
159
|
+
- role_id: string # developer | arquitetos-software | security-champion | ...
|
|
160
|
+
- aliases: list[string]
|
|
161
|
+
|
|
162
|
+
MaturityMapping:
|
|
163
|
+
description: "Mapeamento de maturidade para frameworks externos (OWASP SAMM, etc.)"
|
|
164
|
+
source_file: "data/entities/maturity_mappings.json"
|
|
165
|
+
id_field: "id"
|
|
166
|
+
attributes:
|
|
167
|
+
- id: string
|
|
168
|
+
- framework: string # OWASP SAMM v2.1 | NIST | ISO 27001 | ...
|
|
169
|
+
- framework_area: string
|
|
170
|
+
- chapter_id: string
|
|
171
|
+
- coverage_summary: string
|
|
172
|
+
|
|
173
|
+
ImplementationRule:
|
|
174
|
+
description: >-
|
|
175
|
+
Regra concreta prescritiva para geração de código seguro.
|
|
176
|
+
Camada intermédia entre Practice e o LLM/agente — mais prescritiva que user story.
|
|
177
|
+
source_file: null # a popular em extração futura
|
|
178
|
+
id_field: "rule_id"
|
|
179
|
+
attributes:
|
|
180
|
+
- rule_id: string # ex: IMPL-LOG-001
|
|
181
|
+
- description: string # ex: "não registar tokens em logs"
|
|
182
|
+
- domain: string # alinhado com control.domain
|
|
183
|
+
- applies_to_artifact_types: list[string] # ex: [http_endpoint, worker]
|
|
184
|
+
- mandatory: boolean
|
|
185
|
+
- forbidden_examples: list[string] # anti-patterns concretos
|
|
186
|
+
- recommended_evidence: string # ex: "teste negativo que verifica ausência de token"
|
|
187
|
+
- maps_to_requirement_ids: list[string]
|
|
188
|
+
- maps_to_control_id: string
|
|
189
|
+
|
|
190
|
+
EvidencePattern:
|
|
191
|
+
description: >-
|
|
192
|
+
Padrão de evidência observável — permite review determinístico.
|
|
193
|
+
Liga artefactos/sinais concretos a requisitos esperados.
|
|
194
|
+
source_file: "data/entities/evidence_patterns.json"
|
|
195
|
+
source_documents:
|
|
196
|
+
- "data/source/SbD-ToE-Manual/manuals_src/docs/sbd-toe/010-sbd-manual/02-requisitos-seguranca/addon/10-validacao-requisitos.md"
|
|
197
|
+
- "data/source/SbD-ToE-Manual/manuals_src/docs/sbd-toe/010-sbd-manual/04-arquitetura-segura/addon/05-validacao.md"
|
|
198
|
+
coverage:
|
|
199
|
+
populated: [AUT, CFG, VAL, LOG, API, ARC, ENC] # categorias com evidências documentadas
|
|
200
|
+
stub: [ACC, SES, ERR, INT, REQ, DST, IDE, IAC] # sem cobertura nos docs de validação
|
|
201
|
+
note: >-
|
|
202
|
+
ENC foi adicionado ao canónico como lacuna do manual (10 requisitos de criptografia).
|
|
203
|
+
O doc 10-validacao-requisitos.md é a fonte originária destes requisitos e evidências.
|
|
204
|
+
id_field: "id"
|
|
205
|
+
attributes:
|
|
206
|
+
- id: string # ex: EP-LOG-001
|
|
207
|
+
- evidence_type: enum[file, test, config, log, workflow, policy]
|
|
208
|
+
- detectable_in: list[string] # ex: [src/, .github/workflows/, Dockerfile]
|
|
209
|
+
- detection_hint: string # ex: "presença de structured logger import"
|
|
210
|
+
- maps_to_requirement_id: string # ex: LOG-003
|
|
211
|
+
- maps_to_control_id: string
|
|
212
|
+
- confidence_when_present: enum[high, medium, low]
|
|
213
|
+
|
|
214
|
+
ArtifactRequirement:
|
|
215
|
+
description: >-
|
|
216
|
+
Requisito de artefacto — liga um artefacto concreto aos controlos que o exigem
|
|
217
|
+
e às práticas que o produzem. Fonte primária do sinal de confiança 'direct' no
|
|
218
|
+
traversal Requirement → Control.
|
|
219
|
+
source_file: "data/entities/artifact_requirements.json"
|
|
220
|
+
id_field: "id"
|
|
221
|
+
attributes:
|
|
222
|
+
- id: string
|
|
223
|
+
- artifact_type_id: string # referência a Artifact.artifact_type_id
|
|
224
|
+
- source_control_ids: list[string] # controlos que exigem este artefacto
|
|
225
|
+
- source_practice_ids: list[string]
|
|
226
|
+
- chapter_id: string
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
230
|
+
# DOMAIN MAPPING
|
|
231
|
+
# Liga categorias de requisitos a domínios de controlo
|
|
232
|
+
# Esta é a "chave" para traversal Requirement → Control
|
|
233
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
234
|
+
|
|
235
|
+
domain_mapping:
|
|
236
|
+
# requirement category → control domain(s)
|
|
237
|
+
|
|
238
|
+
# Cap 02 — Base security requirements (12 categories)
|
|
239
|
+
AUT: [identity, governance] # Autenticação e Identidade
|
|
240
|
+
ACC: [identity] # Controlo de Acesso
|
|
241
|
+
LOG: [monitoring] # Registo e Monitorização
|
|
242
|
+
SES: [identity] # Sessões e Estado
|
|
243
|
+
VAL: [code_integrity] # Validação de Entrada
|
|
244
|
+
ERR: [code_integrity, governance] # Gestão de Erros
|
|
245
|
+
CFG: [infrastructure, governance] # Configuração e Ambiente
|
|
246
|
+
API: [identity, code_integrity] # Segurança de APIs
|
|
247
|
+
INT: [code_integrity, secrets] # Integridade e Integração
|
|
248
|
+
REQ: [governance] # Requisitos de Segurança no SDLC
|
|
249
|
+
DST: [supply_chain, code_integrity] # Distribuição e Supply Chain
|
|
250
|
+
IDE: [governance, code_integrity] # Ambiente de Desenvolvimento
|
|
251
|
+
|
|
252
|
+
# Cap 04 — Architecture requirements
|
|
253
|
+
ARC: [governance, identity, infrastructure, monitoring]
|
|
254
|
+
|
|
255
|
+
# Cap 08 — Infrastructure-as-Code requirements
|
|
256
|
+
IAC: [infrastructure, supply_chain, secrets]
|
|
257
|
+
|
|
258
|
+
# Cap 02 — Criptografia e Dados Sensíveis (lacuna do catálogo original; adicionado como ENC)
|
|
259
|
+
ENC: [secrets, code_integrity] # ENC-001..ENC-010 — temporariamente no canónico até actualização do manual
|
|
260
|
+
|
|
261
|
+
# Nota: 8 domínios canónicos = code_integrity | governance | identity | infrastructure
|
|
262
|
+
# | monitoring | secrets | supply_chain | testing
|
|
263
|
+
# O domínio 'testing' é ativado indiretamente via REQ (source_practice_ids
|
|
264
|
+
# ligam práticas de teste aos controlos do domínio testing).
|
|
265
|
+
# Não existe mapeamento direto categoria→testing para evitar ativação generalista.
|
|
266
|
+
# Quando EvidencePattern for populado, REQ poderá mapear também para testing.
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
270
|
+
# RELATIONS
|
|
271
|
+
# Relações explícitas (derivadas dos dados) e inferidas (pela engine)
|
|
272
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
273
|
+
|
|
274
|
+
relations:
|
|
275
|
+
|
|
276
|
+
# Derivadas diretamente dos dados
|
|
277
|
+
explicit:
|
|
278
|
+
|
|
279
|
+
control_produces_artifact:
|
|
280
|
+
from: Control
|
|
281
|
+
to: Artifact
|
|
282
|
+
via: "control.artifact_types ↔ artifact.artifact_type_id"
|
|
283
|
+
cardinality: one_to_many
|
|
284
|
+
|
|
285
|
+
control_implemented_by_practice:
|
|
286
|
+
from: Control
|
|
287
|
+
to: Practice
|
|
288
|
+
via: "control.source_practice_ids ↔ practice.id"
|
|
289
|
+
cardinality: one_to_many
|
|
290
|
+
|
|
291
|
+
control_applies_in_phase:
|
|
292
|
+
from: Control
|
|
293
|
+
to: SDLCPhase
|
|
294
|
+
via: "control.applicable_lifecycle_phases ↔ phase.phase_id + aliases"
|
|
295
|
+
cardinality: many_to_many
|
|
296
|
+
|
|
297
|
+
practice_has_user_story:
|
|
298
|
+
from: Practice
|
|
299
|
+
to: UserStory
|
|
300
|
+
via: "user_story.practice_id == practice.id"
|
|
301
|
+
cardinality: one_to_many
|
|
302
|
+
|
|
303
|
+
assignment_assigns_role:
|
|
304
|
+
from: PracticeAssignment
|
|
305
|
+
to: Role
|
|
306
|
+
via: "assignment.role ↔ role.role_id + aliases"
|
|
307
|
+
cardinality: many_to_one
|
|
308
|
+
|
|
309
|
+
assignment_occurs_in_phase:
|
|
310
|
+
from: PracticeAssignment
|
|
311
|
+
to: SDLCPhase
|
|
312
|
+
via: "assignment.phase ↔ phase.phase_id + aliases"
|
|
313
|
+
cardinality: many_to_one
|
|
314
|
+
|
|
315
|
+
assignment_at_risk_level:
|
|
316
|
+
from: PracticeAssignment
|
|
317
|
+
to_value: "assignment.risk_level"
|
|
318
|
+
note: "L1 | L2 | L3"
|
|
319
|
+
|
|
320
|
+
artifact_req_links_control:
|
|
321
|
+
from: ArtifactRequirement
|
|
322
|
+
to: Control
|
|
323
|
+
via: "artifact_requirement.source_control_ids ↔ control.control_id"
|
|
324
|
+
cardinality: many_to_many
|
|
325
|
+
note: >-
|
|
326
|
+
Linkagem directa artefacto→controlo. Usada como sinal de confiança 'direct'
|
|
327
|
+
quando o controlo já está ativo por domain_mapping. Fonte:
|
|
328
|
+
data/entities/artifact_requirements.json
|
|
329
|
+
|
|
330
|
+
implementation_rule_refines_requirement:
|
|
331
|
+
from: ImplementationRule
|
|
332
|
+
to: Requirement
|
|
333
|
+
via: "implementation_rule.maps_to_requirement_ids ↔ requirement.requirement_id"
|
|
334
|
+
cardinality: many_to_many
|
|
335
|
+
note: "Stub — relação activa quando ImplementationRule.source_file for populado"
|
|
336
|
+
|
|
337
|
+
implementation_rule_implements_control:
|
|
338
|
+
from: ImplementationRule
|
|
339
|
+
to: Control
|
|
340
|
+
via: "implementation_rule.maps_to_control_id ↔ control.control_id"
|
|
341
|
+
cardinality: many_to_one
|
|
342
|
+
note: "Stub — relação activa quando ImplementationRule.source_file for populado"
|
|
343
|
+
|
|
344
|
+
evidence_pattern_validates_requirement:
|
|
345
|
+
from: EvidencePattern
|
|
346
|
+
to: Requirement
|
|
347
|
+
via: "evidence_pattern.maps_to_requirement_id ↔ requirement.requirement_id"
|
|
348
|
+
cardinality: many_to_one
|
|
349
|
+
note: "Parcialmente populado: categorias AUT, CFG, VAL, LOG, API (Cap02) + ARC (Cap04)"
|
|
350
|
+
|
|
351
|
+
evidence_pattern_validates_control:
|
|
352
|
+
from: EvidencePattern
|
|
353
|
+
to: Control
|
|
354
|
+
via: "evidence_pattern.maps_to_control_id ↔ control.control_id"
|
|
355
|
+
cardinality: many_to_one
|
|
356
|
+
note: "Parcialmente populado: activo nas mesmas categorias que evidence_pattern_validates_requirement"
|
|
357
|
+
|
|
358
|
+
# Inferidas pela engine via domain_mapping
|
|
359
|
+
inferred:
|
|
360
|
+
|
|
361
|
+
requirement_maps_to_control:
|
|
362
|
+
from: Requirement
|
|
363
|
+
to: Control
|
|
364
|
+
via: "domain_mapping[requirement.category] ∩ control.domain"
|
|
365
|
+
confidence: derived
|
|
366
|
+
note: >-
|
|
367
|
+
Mecanismo primário de traversal enquanto não existir mapeamento direct explícito
|
|
368
|
+
por requirement_id canónico. domain_mapping é o fallback universal.
|
|
369
|
+
|
|
370
|
+
requirement_maps_to_control_direct:
|
|
371
|
+
from: Requirement
|
|
372
|
+
to: Control
|
|
373
|
+
via: "future: explicit req_id → ctrl_id table"
|
|
374
|
+
confidence: direct
|
|
375
|
+
note: >-
|
|
376
|
+
Quando existir: usar como relação primária, domain_mapping como fallback.
|
|
377
|
+
Estrutura: [{requirement_id, control_id, strength: direct|derived}]
|
|
378
|
+
|
|
379
|
+
requirement_applies_to_application:
|
|
380
|
+
from: Requirement
|
|
381
|
+
to: Application
|
|
382
|
+
via: "RULE: REQUIREMENT_APPLIES_BY_RISK"
|
|
383
|
+
|
|
384
|
+
threat_mitigated_by_control:
|
|
385
|
+
from: Threat
|
|
386
|
+
to: Control
|
|
387
|
+
via: "threat.associated_controls"
|
|
388
|
+
confidence_levels:
|
|
389
|
+
direct: "associação explicitamente mapeada req_id→ctrl_id"
|
|
390
|
+
derived: "derivada por categoria/capítulo/domínio partilhado"
|
|
391
|
+
heuristic: "match de texto parcial em associated_controls"
|
|
392
|
+
note: "Engine devolve mitigation_link_type por cada relação ameaça→controlo"
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
396
|
+
# INFERENCE RULES
|
|
397
|
+
# Regras determinísticas usadas pelo OntologyEngine
|
|
398
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
399
|
+
|
|
400
|
+
# Metadados de regras:
|
|
401
|
+
# priority: ordem de aplicação (100 = mais alto); regras com même priority correm em paralelo
|
|
402
|
+
# rule_type: additive (adiciona ao conjunto) | restrictive (filtra) | override (substitui)
|
|
403
|
+
# conflicts: regras com as quais pode colidir (resolução: priority wins)
|
|
404
|
+
|
|
405
|
+
rules:
|
|
406
|
+
|
|
407
|
+
REQUIREMENT_APPLIES_BY_RISK:
|
|
408
|
+
description: "Um requisito aplica-se se o nível de risco da aplicação o exige"
|
|
409
|
+
priority: 100
|
|
410
|
+
rule_type: additive
|
|
411
|
+
condition:
|
|
412
|
+
- "application.risk_level in [L1, L2, L3]"
|
|
413
|
+
- "requirement.applicable_levels[application.risk_level] == true"
|
|
414
|
+
result: "requirement is applicable"
|
|
415
|
+
note: >
|
|
416
|
+
L3 inclui tudo (L1+L2+L3).
|
|
417
|
+
L2 inclui L1+L2.
|
|
418
|
+
L1 inclui apenas L1.
|
|
419
|
+
|
|
420
|
+
CONTROL_ACTIVE_FROM_REQUIREMENT:
|
|
421
|
+
description: "Um controlo ativa-se se algum requisito aplicável mapeia para o seu domínio"
|
|
422
|
+
priority: 90
|
|
423
|
+
rule_type: additive
|
|
424
|
+
condition:
|
|
425
|
+
- "requirement is applicable"
|
|
426
|
+
- "requirement.category in domain_mapping"
|
|
427
|
+
- "control.domain in domain_mapping[requirement.category]"
|
|
428
|
+
result: "control is active (confidence=derived)"
|
|
429
|
+
|
|
430
|
+
PRACTICE_ACTIVE_FROM_CONTROL:
|
|
431
|
+
description: "Uma prática ativa-se se o controlo que a implementa está ativo"
|
|
432
|
+
priority: 80
|
|
433
|
+
rule_type: additive
|
|
434
|
+
condition:
|
|
435
|
+
- "control is active"
|
|
436
|
+
- "practice.id in control.source_practice_ids"
|
|
437
|
+
result: "practice is active"
|
|
438
|
+
|
|
439
|
+
ASSIGNMENT_ACTIVE_BY_RISK:
|
|
440
|
+
description: "Uma tarefa é relevante se o nível de risco a inclui"
|
|
441
|
+
priority: 70
|
|
442
|
+
rule_type: additive
|
|
443
|
+
condition:
|
|
444
|
+
- "practice is active"
|
|
445
|
+
- "assignment.practice_id == practice.id"
|
|
446
|
+
- "assignment.risk_level <= application.risk_level"
|
|
447
|
+
result: "assignment is active"
|
|
448
|
+
risk_ordering: "L1 < L2 < L3"
|
|
449
|
+
|
|
450
|
+
ARTIFACT_REQUIRED_FROM_CONTROL:
|
|
451
|
+
description: "Um artefacto é exigido se o controlo que o produz está ativo"
|
|
452
|
+
priority: 80
|
|
453
|
+
rule_type: additive
|
|
454
|
+
condition:
|
|
455
|
+
- "control is active"
|
|
456
|
+
- "artifact.artifact_type_id in control.artifact_types (normalized)"
|
|
457
|
+
result: "artifact is required"
|
|
458
|
+
|
|
459
|
+
THREAT_MODEL_REQUIRED_L2:
|
|
460
|
+
description: "Threat modeling é obrigatório a partir de L2"
|
|
461
|
+
priority: 95
|
|
462
|
+
rule_type: additive
|
|
463
|
+
conflicts: []
|
|
464
|
+
condition:
|
|
465
|
+
- "application.risk_level in [L2, L3]"
|
|
466
|
+
result: "ARC requirements apply"
|
|
467
|
+
note: "Ativa todas as requirements com category=ARC"
|
|
468
|
+
|
|
469
|
+
IAC_REQUIRED_L2:
|
|
470
|
+
description: "Requisitos de IaC aplicam-se a partir de L2"
|
|
471
|
+
priority: 95
|
|
472
|
+
rule_type: additive
|
|
473
|
+
conflicts: []
|
|
474
|
+
condition:
|
|
475
|
+
- "application.risk_level in [L2, L3]"
|
|
476
|
+
result: "IAC requirements apply"
|
|
477
|
+
note: "Ativa todas as requirements com category=IAC"
|
|
478
|
+
|
|
479
|
+
EXPOSURE_AMPLIFIES_REQUIREMENTS:
|
|
480
|
+
description: "Exposição pública ou dados regulados ampliam requisitos aplicáveis"
|
|
481
|
+
priority: 85
|
|
482
|
+
rule_type: additive
|
|
483
|
+
conflicts: [] # não conflitua; apenas adiciona ao conjunto de L1
|
|
484
|
+
condition:
|
|
485
|
+
- "application.exposure in [public, authenticated]"
|
|
486
|
+
- "OR application.data_sensitivity in [regulated, secrets]"
|
|
487
|
+
result: "apply AUT + ACC + API + INT + SES requirements regardless of L1"
|
|
488
|
+
note: "Garante baseline de auth/access mesmo em L1 público"
|
|
489
|
+
|
|
490
|
+
CONCERNS_FILTER_REQUIREMENTS:
|
|
491
|
+
description: >-
|
|
492
|
+
Se application.concerns definidos, projeta um subconjunto de requisitos como
|
|
493
|
+
'primary focus'. Não remove os restantes — mantém-nos como contexto secundário.
|
|
494
|
+
priority: 60
|
|
495
|
+
rule_type: projection
|
|
496
|
+
conflicts: []
|
|
497
|
+
condition:
|
|
498
|
+
- "application.concerns is not empty"
|
|
499
|
+
- "requirement.category in concern_mapped_categories(application.concerns)"
|
|
500
|
+
result: "tag matching requirements with focus=true; all others remain active with focus=false"
|
|
501
|
+
note: >-
|
|
502
|
+
Projeção não normativa: o conjunto base de requisitos (filtrado por REQUIREMENT_APPLIES_BY_RISK)
|
|
503
|
+
mantém-se intacto. O consumer (MCP/agente) usa focus=true para priorizar,
|
|
504
|
+
nunca para excluir. ex. concerns=[logging] → LOG requirements são focus=true,
|
|
505
|
+
os restantes mantêm-se mas são focus=false.
|
|
506
|
+
|
|
507
|
+
|
|
508
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
509
|
+
# RESOLUTION PIPELINES
|
|
510
|
+
# Sequências canónicas de resolução para cada tipo de consulta
|
|
511
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
512
|
+
|
|
513
|
+
resolution_pipelines:
|
|
514
|
+
|
|
515
|
+
consult:
|
|
516
|
+
description: "O que se aplica à minha aplicação?"
|
|
517
|
+
steps:
|
|
518
|
+
1: "Application → [REQUIREMENT_APPLIES_BY_RISK] → applicable_requirements"
|
|
519
|
+
2: "applicable_requirements → [CONTROL_ACTIVE_FROM_REQUIREMENT] → active_controls"
|
|
520
|
+
3: "active_controls → artifacts → required_artifacts"
|
|
521
|
+
4: "[THREAT_MODEL_REQUIRED_L2 | IAC_REQUIRED_L2] → extra_requirements"
|
|
522
|
+
output:
|
|
523
|
+
- applicable_requirements: list[Requirement]
|
|
524
|
+
- active_controls: list[Control]
|
|
525
|
+
- required_artifacts: list[Artifact]
|
|
526
|
+
- applicable_categories: list[string]
|
|
527
|
+
|
|
528
|
+
guide:
|
|
529
|
+
description: "Como implementar? (código, pipeline, config)"
|
|
530
|
+
steps:
|
|
531
|
+
1: "Application → applicable_requirements → active_controls"
|
|
532
|
+
2: "active_controls → [PRACTICE_ACTIVE_FROM_CONTROL] → active_practices"
|
|
533
|
+
3: "active_practices → user_stories → checklist_items"
|
|
534
|
+
4: "active_practices → [ASSIGNMENT_ACTIVE_BY_RISK] → active_assignments"
|
|
535
|
+
5: "active_assignments → role + phase"
|
|
536
|
+
output:
|
|
537
|
+
- active_practices: list[Practice]
|
|
538
|
+
- active_assignments: list[PracticeAssignment]
|
|
539
|
+
- user_stories: list[UserStory]
|
|
540
|
+
- by_role: dict[role → list[action]]
|
|
541
|
+
- by_phase: dict[phase → list[action]]
|
|
542
|
+
|
|
543
|
+
review:
|
|
544
|
+
description: "O meu código/sistema cumpre?"
|
|
545
|
+
steps:
|
|
546
|
+
1: "Application → [REQUIREMENT_APPLIES_BY_RISK] → applicable_requirements"
|
|
547
|
+
2: "applicable_requirements → [CONTROL_ACTIVE_FROM_REQUIREMENT] → active_controls"
|
|
548
|
+
3: "applicable_requirements → [evidence_pattern_validates_requirement] → expected_evidence_patterns"
|
|
549
|
+
4: "expected_evidence_patterns → match supplied_code_context → present | absent"
|
|
550
|
+
5: "absent evidence_patterns → map back to requirements → gaps"
|
|
551
|
+
6: "gaps → active_controls → risk_exposure"
|
|
552
|
+
output:
|
|
553
|
+
- compliant: list[Requirement]
|
|
554
|
+
- gaps: list[Requirement]
|
|
555
|
+
- missing_artifacts: list[Artifact]
|
|
556
|
+
- missing_evidence: list[EvidencePattern]
|
|
557
|
+
- risk_exposure: string
|
|
558
|
+
note: >-
|
|
559
|
+
Steps 3-5 operacionais para categorias AUT, CFG, VAL, LOG, API, ARC (evidências documentadas).
|
|
560
|
+
Categorias ACC, SES, ERR, INT, REQ, DST, IDE, IAC mantêm-se stub até extracção futura.
|
|
561
|
+
Steps 1-2+6 funcionam para todas as categorias.
|
|
562
|
+
|
|
563
|
+
threats:
|
|
564
|
+
description: "Que ameaças existem? O que mitiga?"
|
|
565
|
+
steps:
|
|
566
|
+
1: "Application.chapter_context → filter threats by chapter_id"
|
|
567
|
+
2: "threats → associated_controls → map to active_controls"
|
|
568
|
+
3: "active_controls → practices → mitigations"
|
|
569
|
+
output:
|
|
570
|
+
- applicable_threats: list[Threat]
|
|
571
|
+
- mitigated_by: dict[threat → list[Control]]
|
|
572
|
+
- unmitigated: list[Threat]
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
576
|
+
# CATEGORY REGISTRY
|
|
577
|
+
# Metadata de todas as 14 categorias de requisitos
|
|
578
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
579
|
+
|
|
580
|
+
categories:
|
|
581
|
+
|
|
582
|
+
# Cap 02 — Base
|
|
583
|
+
AUT:
|
|
584
|
+
label: "Autenticação e Identidade"
|
|
585
|
+
source_chapter: 2
|
|
586
|
+
count: 10
|
|
587
|
+
min_risk_level: L1
|
|
588
|
+
related_domains: [identity, governance]
|
|
589
|
+
|
|
590
|
+
ACC:
|
|
591
|
+
label: "Controlo de Acesso"
|
|
592
|
+
source_chapter: 2
|
|
593
|
+
count: 10
|
|
594
|
+
min_risk_level: L1
|
|
595
|
+
related_domains: [identity]
|
|
596
|
+
|
|
597
|
+
LOG:
|
|
598
|
+
label: "Registo e Monitorização"
|
|
599
|
+
source_chapter: 2
|
|
600
|
+
count: 10
|
|
601
|
+
min_risk_level: L1
|
|
602
|
+
related_domains: [monitoring]
|
|
603
|
+
|
|
604
|
+
SES:
|
|
605
|
+
label: "Sessões e Estado"
|
|
606
|
+
source_chapter: 2
|
|
607
|
+
count: 8
|
|
608
|
+
min_risk_level: L1
|
|
609
|
+
related_domains: [identity]
|
|
610
|
+
|
|
611
|
+
VAL:
|
|
612
|
+
label: "Validação de Entrada"
|
|
613
|
+
source_chapter: 2
|
|
614
|
+
count: 7
|
|
615
|
+
min_risk_level: L1
|
|
616
|
+
related_domains: [code_integrity]
|
|
617
|
+
|
|
618
|
+
ERR:
|
|
619
|
+
label: "Gestão de Erros"
|
|
620
|
+
source_chapter: 2
|
|
621
|
+
count: 7
|
|
622
|
+
min_risk_level: L1
|
|
623
|
+
related_domains: [code_integrity, governance]
|
|
624
|
+
|
|
625
|
+
CFG:
|
|
626
|
+
label: "Configuração e Ambiente"
|
|
627
|
+
source_chapter: 2
|
|
628
|
+
count: 7
|
|
629
|
+
min_risk_level: L1
|
|
630
|
+
related_domains: [infrastructure, governance]
|
|
631
|
+
|
|
632
|
+
API:
|
|
633
|
+
label: "Segurança de APIs"
|
|
634
|
+
source_chapter: 2
|
|
635
|
+
count: 7
|
|
636
|
+
min_risk_level: L1
|
|
637
|
+
related_domains: [identity, code_integrity]
|
|
638
|
+
|
|
639
|
+
INT:
|
|
640
|
+
label: "Integridade e Integração"
|
|
641
|
+
source_chapter: 2
|
|
642
|
+
count: 8
|
|
643
|
+
min_risk_level: L1
|
|
644
|
+
related_domains: [code_integrity, secrets]
|
|
645
|
+
|
|
646
|
+
REQ:
|
|
647
|
+
label: "Requisitos de Segurança no SDLC"
|
|
648
|
+
source_chapter: 2
|
|
649
|
+
count: 7
|
|
650
|
+
min_risk_level: L1
|
|
651
|
+
related_domains: [governance]
|
|
652
|
+
|
|
653
|
+
DST:
|
|
654
|
+
label: "Distribuição e Supply Chain"
|
|
655
|
+
source_chapter: 2
|
|
656
|
+
count: 7
|
|
657
|
+
min_risk_level: L1
|
|
658
|
+
related_domains: [supply_chain, code_integrity]
|
|
659
|
+
|
|
660
|
+
IDE:
|
|
661
|
+
label: "Ambiente de Desenvolvimento"
|
|
662
|
+
source_chapter: 2
|
|
663
|
+
count: 6
|
|
664
|
+
min_risk_level: L1
|
|
665
|
+
related_domains: [governance, code_integrity]
|
|
666
|
+
|
|
667
|
+
# Cap 04 — Architecture
|
|
668
|
+
ARC:
|
|
669
|
+
label: "Requisitos de Arquitetura Segura"
|
|
670
|
+
source_chapter: 4
|
|
671
|
+
count: 13
|
|
672
|
+
min_risk_level: L2
|
|
673
|
+
related_domains: [governance, identity, infrastructure, monitoring]
|
|
674
|
+
|
|
675
|
+
# Cap 08 — Infrastructure-as-Code
|
|
676
|
+
IAC:
|
|
677
|
+
label: "Infraestrutura como Código"
|
|
678
|
+
source_chapter: 8
|
|
679
|
+
count: 13
|
|
680
|
+
min_risk_level: L2
|
|
681
|
+
related_domains: [infrastructure, supply_chain, secrets]
|
|
682
|
+
|
|
683
|
+
# Cap 02 — Criptografia e Dados Sensíveis (adicionado como lacuna do manual)
|
|
684
|
+
ENC:
|
|
685
|
+
label: "Criptografia e Dados Sensíveis"
|
|
686
|
+
source_chapter: 2
|
|
687
|
+
count: 10
|
|
688
|
+
min_risk_level: L1
|
|
689
|
+
related_domains: [secrets, code_integrity]
|
|
690
|
+
note: >-
|
|
691
|
+
Categoria adicionada temporariamente ao canónico com base em 10-validacao-requisitos.md.
|
|
692
|
+
Lacuna identificada: não existia no catálogo original extraido do Cap 02.
|
|
693
|
+
Candidatos a absorver em cate gorias existentes quando o manual for actualizado:
|
|
694
|
+
ENC-001 → INT-003 (TLS), ENC-004 → AUT-006 (hashing), ENC-005/ENC-008 → CFG-006 (cofre),
|
|
695
|
+
ENC-009 → DST/IDE (secret scanning), ENC-007 → LOG (masking).
|
|
696
|
+
Requisitos sem contraparte directa: ENC-002, ENC-003, ENC-010 (lacunas reais).
|