Skip to content

Commit 649fbcd

Browse files
authored
feat: add components to filters (#307)
* feat: add components to filters * chore: update swagger * fix: single query for component definition, rename association table, fix edgecase for filter list * chore: remove unused (but contextually valuable) code, still exists in vcs for us to return to * feat: update defined component -> system component * chore: fix merge conflicts
1 parent 5cb2678 commit 649fbcd

File tree

17 files changed

+360
-226
lines changed

17 files changed

+360
-226
lines changed

cmd/oscal/import.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
133133
sugar.Error(err)
134134
}
135135

136+
imported := false
137+
136138
if input.Catalog != nil {
137139
def := &relational.Catalog{}
138140
def.UnmarshalOscal(*input.Catalog)
@@ -141,7 +143,7 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
141143
sugar.Error(out.Error)
142144
}
143145
sugar.Infow("Successfully Created Catalog", "title", def.Metadata.Title, "file", f.Name())
144-
return nil
146+
imported = true
145147
}
146148

147149
if input.ComponentDefinition != nil {
@@ -152,7 +154,7 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
152154
sugar.Error(out.Error)
153155
}
154156
sugar.Infow("Successfully Created Component Definition", "title", def.Metadata.Title, "file", f.Name())
155-
return nil
157+
imported = true
156158
}
157159

158160
if input.SystemSecurityPlan != nil {
@@ -163,7 +165,7 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
163165
sugar.Error(out.Error)
164166
}
165167
sugar.Infow("Successfully Created System Security Plan", "title", def.Metadata.Title, "file", f.Name())
166-
return nil
168+
imported = true
167169
}
168170

169171
if input.AssessmentPlan != nil {
@@ -174,7 +176,7 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
174176
panic(out.Error)
175177
}
176178
sugar.Infow("Successfully Created Assessment Plan", "title", def.Metadata.Title, "file", f.Name())
177-
return nil
179+
imported = true
178180
}
179181

180182
if input.AssessmentResult != nil {
@@ -185,7 +187,7 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
185187
panic(out.Error)
186188
}
187189
sugar.Infow("Successfully Created Assessment Result", "title", def.Metadata.Title, "file", f.Name())
188-
return nil
190+
imported = true
189191
}
190192

191193
if input.Profile != nil {
@@ -204,7 +206,7 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
204206
}
205207

206208
sugar.Infow("Successfully Created Profile", "title", def.Metadata.Title, "file", f.Name())
207-
return nil
209+
imported = true
208210
}
209211

210212
if input.PlanOfActionAndMilestones != nil {
@@ -222,6 +224,10 @@ func importFile(db *gorm.DB, sugar *zap.SugaredLogger, f *os.File) error {
222224
return err
223225
}
224226
sugar.Infow("Successfully Created Plan of Action and Milestones", "title", def.Metadata.Title, "file", f.Name())
227+
imported = true
228+
}
229+
230+
if imported {
225231
return nil
226232
}
227233

docs/docs.go

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ const docTemplate = `{
10511051
"200": {
10521052
"description": "OK",
10531053
"schema": {
1054-
"$ref": "#/definitions/handler.GenericDataListResponse-handler_FilterWithControlsResponse"
1054+
"$ref": "#/definitions/handler.GenericDataListResponse-handler_FilterWithControlsAndComponentsResponse"
10551055
}
10561056
},
10571057
"500": {
@@ -1180,7 +1180,7 @@ const docTemplate = `{
11801180
"200": {
11811181
"description": "OK",
11821182
"schema": {
1183-
"$ref": "#/definitions/handler.GenericDataResponse-handler_FilterWithControlsResponse"
1183+
"$ref": "#/definitions/handler.GenericDataResponse-handler_FilterWithControlsAndComponentsResponse"
11841184
}
11851185
},
11861186
"400": {
@@ -16568,9 +16568,15 @@ const docTemplate = `{
1656816568
}
1656916569
}
1657016570
},
16571-
"handler.FilterWithControlsResponse": {
16571+
"handler.FilterWithControlsAndComponentsResponse": {
1657216572
"type": "object",
1657316573
"properties": {
16574+
"components": {
16575+
"type": "array",
16576+
"items": {
16577+
"$ref": "#/definitions/oscalTypes_1_1_3.SystemComponent"
16578+
}
16579+
},
1657416580
"controls": {
1657516581
"type": "array",
1657616582
"items": {
@@ -16638,14 +16644,14 @@ const docTemplate = `{
1663816644
}
1663916645
}
1664016646
},
16641-
"handler.GenericDataListResponse-handler_FilterWithControlsResponse": {
16647+
"handler.GenericDataListResponse-handler_FilterWithControlsAndComponentsResponse": {
1664216648
"type": "object",
1664316649
"properties": {
1664416650
"data": {
1664516651
"description": "Items from the list response",
1664616652
"type": "array",
1664716653
"items": {
16648-
"$ref": "#/definitions/handler.FilterWithControlsResponse"
16654+
"$ref": "#/definitions/handler.FilterWithControlsAndComponentsResponse"
1664916655
}
1665016656
}
1665116657
}
@@ -17168,14 +17174,14 @@ const docTemplate = `{
1716817174
}
1716917175
}
1717017176
},
17171-
"handler.GenericDataResponse-handler_FilterWithControlsResponse": {
17177+
"handler.GenericDataResponse-handler_FilterWithControlsAndComponentsResponse": {
1717217178
"type": "object",
1717317179
"properties": {
1717417180
"data": {
1717517181
"description": "Items from the list response",
1717617182
"allOf": [
1717717183
{
17178-
"$ref": "#/definitions/handler.FilterWithControlsResponse"
17184+
"$ref": "#/definitions/handler.FilterWithControlsAndComponentsResponse"
1717917185
}
1718017186
]
1718117187
}
@@ -18091,6 +18097,12 @@ const docTemplate = `{
1809118097
"name"
1809218098
],
1809318099
"properties": {
18100+
"components": {
18101+
"type": "array",
18102+
"items": {
18103+
"type": "string"
18104+
}
18105+
},
1809418106
"controls": {
1809518107
"type": "array",
1809618108
"items": {
@@ -23362,6 +23374,12 @@ const docTemplate = `{
2336223374
"relational.Filter": {
2336323375
"type": "object",
2336423376
"properties": {
23377+
"components": {
23378+
"type": "array",
23379+
"items": {
23380+
"$ref": "#/definitions/relational.SystemComponent"
23381+
}
23382+
},
2336523383
"controls": {
2336623384
"type": "array",
2336723385
"items": {
@@ -24536,6 +24554,12 @@ const docTemplate = `{
2453624554
"$ref": "#/definitions/relational.Evidence"
2453724555
}
2453824556
},
24557+
"filters": {
24558+
"type": "array",
24559+
"items": {
24560+
"$ref": "#/definitions/relational.Filter"
24561+
}
24562+
},
2453924563
"id": {
2454024564
"type": "string"
2454124565
},

docs/swagger.json

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,7 +1045,7 @@
10451045
"200": {
10461046
"description": "OK",
10471047
"schema": {
1048-
"$ref": "#/definitions/handler.GenericDataListResponse-handler_FilterWithControlsResponse"
1048+
"$ref": "#/definitions/handler.GenericDataListResponse-handler_FilterWithControlsAndComponentsResponse"
10491049
}
10501050
},
10511051
"500": {
@@ -1174,7 +1174,7 @@
11741174
"200": {
11751175
"description": "OK",
11761176
"schema": {
1177-
"$ref": "#/definitions/handler.GenericDataResponse-handler_FilterWithControlsResponse"
1177+
"$ref": "#/definitions/handler.GenericDataResponse-handler_FilterWithControlsAndComponentsResponse"
11781178
}
11791179
},
11801180
"400": {
@@ -16562,9 +16562,15 @@
1656216562
}
1656316563
}
1656416564
},
16565-
"handler.FilterWithControlsResponse": {
16565+
"handler.FilterWithControlsAndComponentsResponse": {
1656616566
"type": "object",
1656716567
"properties": {
16568+
"components": {
16569+
"type": "array",
16570+
"items": {
16571+
"$ref": "#/definitions/oscalTypes_1_1_3.SystemComponent"
16572+
}
16573+
},
1656816574
"controls": {
1656916575
"type": "array",
1657016576
"items": {
@@ -16632,14 +16638,14 @@
1663216638
}
1663316639
}
1663416640
},
16635-
"handler.GenericDataListResponse-handler_FilterWithControlsResponse": {
16641+
"handler.GenericDataListResponse-handler_FilterWithControlsAndComponentsResponse": {
1663616642
"type": "object",
1663716643
"properties": {
1663816644
"data": {
1663916645
"description": "Items from the list response",
1664016646
"type": "array",
1664116647
"items": {
16642-
"$ref": "#/definitions/handler.FilterWithControlsResponse"
16648+
"$ref": "#/definitions/handler.FilterWithControlsAndComponentsResponse"
1664316649
}
1664416650
}
1664516651
}
@@ -17162,14 +17168,14 @@
1716217168
}
1716317169
}
1716417170
},
17165-
"handler.GenericDataResponse-handler_FilterWithControlsResponse": {
17171+
"handler.GenericDataResponse-handler_FilterWithControlsAndComponentsResponse": {
1716617172
"type": "object",
1716717173
"properties": {
1716817174
"data": {
1716917175
"description": "Items from the list response",
1717017176
"allOf": [
1717117177
{
17172-
"$ref": "#/definitions/handler.FilterWithControlsResponse"
17178+
"$ref": "#/definitions/handler.FilterWithControlsAndComponentsResponse"
1717317179
}
1717417180
]
1717517181
}
@@ -18085,6 +18091,12 @@
1808518091
"name"
1808618092
],
1808718093
"properties": {
18094+
"components": {
18095+
"type": "array",
18096+
"items": {
18097+
"type": "string"
18098+
}
18099+
},
1808818100
"controls": {
1808918101
"type": "array",
1809018102
"items": {
@@ -23356,6 +23368,12 @@
2335623368
"relational.Filter": {
2335723369
"type": "object",
2335823370
"properties": {
23371+
"components": {
23372+
"type": "array",
23373+
"items": {
23374+
"$ref": "#/definitions/relational.SystemComponent"
23375+
}
23376+
},
2335923377
"controls": {
2336023378
"type": "array",
2336123379
"items": {
@@ -24530,6 +24548,12 @@
2453024548
"$ref": "#/definitions/relational.Evidence"
2453124549
}
2453224550
},
24551+
"filters": {
24552+
"type": "array",
24553+
"items": {
24554+
"$ref": "#/definitions/relational.Filter"
24555+
}
24556+
},
2453324557
"id": {
2453424558
"type": "string"
2453524559
},

docs/swagger.yaml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,12 @@ definitions:
305305
total_files:
306306
type: integer
307307
type: object
308-
handler.FilterWithControlsResponse:
308+
handler.FilterWithControlsAndComponentsResponse:
309309
properties:
310+
components:
311+
items:
312+
$ref: '#/definitions/oscalTypes_1_1_3.SystemComponent'
313+
type: array
310314
controls:
311315
items:
312316
$ref: '#/definitions/oscalTypes_1_1_3.Control'
@@ -351,12 +355,12 @@ definitions:
351355
$ref: '#/definitions/handler.ComplianceByControl.StatusCount'
352356
type: array
353357
type: object
354-
handler.GenericDataListResponse-handler_FilterWithControlsResponse:
358+
handler.GenericDataListResponse-handler_FilterWithControlsAndComponentsResponse:
355359
properties:
356360
data:
357361
description: Items from the list response
358362
items:
359-
$ref: '#/definitions/handler.FilterWithControlsResponse'
363+
$ref: '#/definitions/handler.FilterWithControlsAndComponentsResponse'
360364
type: array
361365
type: object
362366
handler.GenericDataListResponse-handler_OscalLikeEvidence:
@@ -701,11 +705,11 @@ definitions:
701705
- $ref: '#/definitions/handler.FilterImportResponse'
702706
description: Items from the list response
703707
type: object
704-
handler.GenericDataResponse-handler_FilterWithControlsResponse:
708+
handler.GenericDataResponse-handler_FilterWithControlsAndComponentsResponse:
705709
properties:
706710
data:
707711
allOf:
708-
- $ref: '#/definitions/handler.FilterWithControlsResponse'
712+
- $ref: '#/definitions/handler.FilterWithControlsAndComponentsResponse'
709713
description: Items from the list response
710714
type: object
711715
handler.GenericDataResponse-handler_OscalLikeEvidence:
@@ -1219,6 +1223,10 @@ definitions:
12191223
type: object
12201224
handler.createFilterRequest:
12211225
properties:
1226+
components:
1227+
items:
1228+
type: string
1229+
type: array
12221230
controls:
12231231
items:
12241232
type: string
@@ -4697,6 +4705,10 @@ definitions:
46974705
type: object
46984706
relational.Filter:
46994707
properties:
4708+
components:
4709+
items:
4710+
$ref: '#/definitions/relational.SystemComponent'
4711+
type: array
47004712
controls:
47014713
items:
47024714
$ref: '#/definitions/relational.Control'
@@ -5483,6 +5495,10 @@ definitions:
54835495
items:
54845496
$ref: '#/definitions/relational.Evidence'
54855497
type: array
5498+
filters:
5499+
items:
5500+
$ref: '#/definitions/relational.Filter'
5501+
type: array
54865502
id:
54875503
type: string
54885504
links:
@@ -6249,7 +6265,7 @@ paths:
62496265
"200":
62506266
description: OK
62516267
schema:
6252-
$ref: '#/definitions/handler.GenericDataListResponse-handler_FilterWithControlsResponse'
6268+
$ref: '#/definitions/handler.GenericDataListResponse-handler_FilterWithControlsAndComponentsResponse'
62536269
"500":
62546270
description: Internal Server Error
62556271
schema:
@@ -6331,7 +6347,7 @@ paths:
63316347
"200":
63326348
description: OK
63336349
schema:
6334-
$ref: '#/definitions/handler.GenericDataResponse-handler_FilterWithControlsResponse'
6350+
$ref: '#/definitions/handler.GenericDataResponse-handler_FilterWithControlsAndComponentsResponse'
63356351
"400":
63366352
description: Bad Request
63376353
schema:

0 commit comments

Comments
 (0)