Skip to content

Commit 8f5475e

Browse files
Priyanshu JaiwarMaxrovr
authored andcommitted
Added - Support for scimQuery field for findingAnalytics API in data safe
1 parent 94aa918 commit 8f5475e

11 files changed

+205
-3
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {
5+
}
6+
7+
variable "user_ocid" {
8+
}
9+
10+
variable "fingerprint" {
11+
}
12+
13+
variable "private_key_path" {
14+
}
15+
16+
variable "region" {
17+
}
18+
19+
variable "compartment_ocid" {
20+
}
21+
22+
variable "data_safe_target_ocid" {
23+
}
24+
variable "security_assessment_ocid" {
25+
26+
}
27+
variable "comp_security_assessment_ocid" {
28+
29+
}
30+
provider "oci" {
31+
version = "7.12.0"
32+
tenancy_ocid = var.tenancy_ocid
33+
user_ocid = var.user_ocid
34+
fingerprint = var.fingerprint
35+
private_key_path = var.private_key_path
36+
region = var.region
37+
}
38+
39+
data "oci_data_safe_security_assessment_comparison" "test_security_assessment_comparison" {
40+
#Required
41+
comparison_security_assessment_id = var.comp_security_assessment_ocid
42+
security_assessment_id = var.security_assessment_ocid
43+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
2+
// Licensed under the Mozilla Public License v2.0
3+
4+
variable "tenancy_ocid" {}
5+
variable "user_ocid" {}
6+
variable "fingerprint" {}
7+
variable "private_key_path" {}
8+
variable "region" {}
9+
variable "compartment_ocid" {}
10+
variable "security_assessment_ocid" {}
11+
variable "data_safe_target_ocid" {}
12+
13+
variable "scim_query" {
14+
default = "severity eq \"HIGH\""
15+
}
16+
17+
provider "oci" {
18+
tenancy_ocid = var.tenancy_ocid
19+
user_ocid = var.user_ocid
20+
fingerprint = var.fingerprint
21+
private_key_path = var.private_key_path
22+
region = var.region
23+
}
24+
25+
data "oci_data_safe_security_assessment_finding_analytics" "test_security_assessment_finding_analytics" {
26+
#Required
27+
compartment_id = var.compartment_ocid
28+
access_level = "ACCESSIBLE"
29+
compartment_id_in_subtree = true
30+
#Optional
31+
scim_query = var.scim_query
32+
}

internal/integrationtest/data_safe_security_assessment_finding_analytic_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ var (
2727
"top_finding_status": acctest.Representation{RepType: acctest.Optional, Create: `RISK`},
2828
}
2929

30+
DataSafeSecurityAssessmentFindingAnalyticScimDataSourceRepresentation = map[string]interface{}{
31+
"compartment_id": acctest.Representation{RepType: acctest.Required, Create: `${var.compartment_id}`},
32+
"access_level": acctest.Representation{RepType: acctest.Optional, Create: `RESTRICTED`},
33+
"compartment_id_in_subtree": acctest.Representation{RepType: acctest.Optional, Create: `false`},
34+
"finding_key": acctest.Representation{RepType: acctest.Optional, Create: `findingKey`},
35+
"scim_query": acctest.Representation{RepType: acctest.Optional, Create: `severity eq \"EVALUATE\"`},
36+
"group_by": acctest.Representation{RepType: acctest.Optional, Create: `findingKeyAndTopFindingStatus`},
37+
"is_top_finding": acctest.Representation{RepType: acctest.Optional, Create: `false`},
38+
"severity": acctest.Representation{RepType: acctest.Optional, Create: `HIGH`},
39+
"top_finding_status": acctest.Representation{RepType: acctest.Optional, Create: `RISK`},
40+
}
41+
3042
DataSafeSecurityAssessmentFindingAnalyticResourceConfig = ""
3143
)
3244

@@ -55,5 +67,16 @@ func TestDataSafeSecurityAssessmentFindingAnalyticResource_basic(t *testing.T) {
5567
resource.TestCheckResourceAttrSet(datasourceName, "finding_analytics_collection.0.items.#"),
5668
),
5769
},
70+
71+
// verify scim datasource
72+
{
73+
Config: config +
74+
acctest.GenerateDataSourceFromRepresentationMap("oci_data_safe_security_assessment_finding_analytics", "test_security_assessment_finding_analytics", acctest.Required, acctest.Create, DataSafeSecurityAssessmentFindingAnalyticScimDataSourceRepresentation) +
75+
compartmentIdVariableStr + DataSafeSecurityAssessmentFindingAnalyticResourceConfig,
76+
Check: acctest.ComposeAggregateTestCheckFuncWrapper(
77+
resource.TestCheckResourceAttrSet(datasourceName, "finding_analytics_collection.#"),
78+
resource.TestCheckResourceAttrSet(datasourceName, "finding_analytics_collection.0.items.#"),
79+
),
80+
},
5881
})
5982
}

internal/integrationtest/data_safe_security_assessment_finding_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ func TestDataSafeSecurityAssessmentFindingResource_basic(t *testing.T) {
6363
acctest.SaveConfigContent("", "", "", t)
6464

6565
acctest.ResourceTest(t, nil, []resource.TestStep{
66+
6667
// verify datasource
6768
{
6869
Config: config +

internal/service/data_safe/data_safe_security_assessment_comparison_data_source.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
128128
Type: schema.TypeString,
129129
Computed: true,
130130
},
131+
"orp": {
132+
Type: schema.TypeString,
133+
Computed: true,
134+
},
131135
"stig": {
132136
Type: schema.TypeString,
133137
Computed: true,
@@ -237,6 +241,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
237241
Type: schema.TypeString,
238242
Computed: true,
239243
},
244+
"orp": {
245+
Type: schema.TypeString,
246+
Computed: true,
247+
},
240248
"stig": {
241249
Type: schema.TypeString,
242250
Computed: true,
@@ -384,6 +392,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
384392
Type: schema.TypeString,
385393
Computed: true,
386394
},
395+
"orp": {
396+
Type: schema.TypeString,
397+
Computed: true,
398+
},
387399
"stig": {
388400
Type: schema.TypeString,
389401
Computed: true,
@@ -493,6 +505,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
493505
Type: schema.TypeString,
494506
Computed: true,
495507
},
508+
"orp": {
509+
Type: schema.TypeString,
510+
Computed: true,
511+
},
496512
"stig": {
497513
Type: schema.TypeString,
498514
Computed: true,
@@ -648,6 +664,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
648664
Type: schema.TypeString,
649665
Computed: true,
650666
},
667+
"orp": {
668+
Type: schema.TypeString,
669+
Computed: true,
670+
},
651671
"stig": {
652672
Type: schema.TypeString,
653673
Computed: true,
@@ -757,6 +777,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
757777
Type: schema.TypeString,
758778
Computed: true,
759779
},
780+
"orp": {
781+
Type: schema.TypeString,
782+
Computed: true,
783+
},
760784
"stig": {
761785
Type: schema.TypeString,
762786
Computed: true,
@@ -904,6 +928,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
904928
Type: schema.TypeString,
905929
Computed: true,
906930
},
931+
"orp": {
932+
Type: schema.TypeString,
933+
Computed: true,
934+
},
907935
"stig": {
908936
Type: schema.TypeString,
909937
Computed: true,
@@ -1013,6 +1041,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
10131041
Type: schema.TypeString,
10141042
Computed: true,
10151043
},
1044+
"orp": {
1045+
Type: schema.TypeString,
1046+
Computed: true,
1047+
},
10161048
"stig": {
10171049
Type: schema.TypeString,
10181050
Computed: true,
@@ -1160,6 +1192,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
11601192
Type: schema.TypeString,
11611193
Computed: true,
11621194
},
1195+
"orp": {
1196+
Type: schema.TypeString,
1197+
Computed: true,
1198+
},
11631199
"stig": {
11641200
Type: schema.TypeString,
11651201
Computed: true,
@@ -1269,6 +1305,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
12691305
Type: schema.TypeString,
12701306
Computed: true,
12711307
},
1308+
"orp": {
1309+
Type: schema.TypeString,
1310+
Computed: true,
1311+
},
12721312
"stig": {
12731313
Type: schema.TypeString,
12741314
Computed: true,
@@ -1416,6 +1456,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
14161456
Type: schema.TypeString,
14171457
Computed: true,
14181458
},
1459+
"orp": {
1460+
Type: schema.TypeString,
1461+
Computed: true,
1462+
},
14191463
"stig": {
14201464
Type: schema.TypeString,
14211465
Computed: true,
@@ -1525,6 +1569,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
15251569
Type: schema.TypeString,
15261570
Computed: true,
15271571
},
1572+
"orp": {
1573+
Type: schema.TypeString,
1574+
Computed: true,
1575+
},
15281576
"stig": {
15291577
Type: schema.TypeString,
15301578
Computed: true,
@@ -1672,6 +1720,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
16721720
Type: schema.TypeString,
16731721
Computed: true,
16741722
},
1723+
"orp": {
1724+
Type: schema.TypeString,
1725+
Computed: true,
1726+
},
16751727
"stig": {
16761728
Type: schema.TypeString,
16771729
Computed: true,
@@ -1781,6 +1833,10 @@ func DataSafeSecurityAssessmentComparisonDataSource() *schema.Resource {
17811833
Type: schema.TypeString,
17821834
Computed: true,
17831835
},
1836+
"orp": {
1837+
Type: schema.TypeString,
1838+
Computed: true,
1839+
},
17841840
"stig": {
17851841
Type: schema.TypeString,
17861842
Computed: true,
@@ -2028,6 +2084,10 @@ func ReferencesToMap(obj *oci_data_safe.References) map[string]interface{} {
20282084
result["obp"] = string(*obj.Obp)
20292085
}
20302086

2087+
if obj.Orp != nil {
2088+
result["orp"] = string(*obj.Orp)
2089+
}
2090+
20312091
if obj.Stig != nil {
20322092
result["stig"] = string(*obj.Stig)
20332093
}

internal/service/data_safe/data_safe_security_assessment_finding_analytics_data_source.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ func DataSafeSecurityAssessmentFindingAnalyticsDataSource() *schema.Resource {
1919
Read: readDataSafeSecurityAssessmentFindingAnalytics,
2020
Schema: map[string]*schema.Schema{
2121
"filter": tfresource.DataSourceFiltersSchema(),
22+
"scim_query": {
23+
Type: schema.TypeString,
24+
Optional: true,
25+
},
2226
"access_level": {
2327
Type: schema.TypeString,
2428
Optional: true,
@@ -166,6 +170,11 @@ func (s *DataSafeSecurityAssessmentFindingAnalyticsDataSourceCrud) Get() error {
166170
request.FindingKey = &tmp
167171
}
168172

173+
if scimQuery, ok := s.D.GetOkExists("scim_query"); ok {
174+
tmp := scimQuery.(string)
175+
request.ScimQuery = &tmp
176+
}
177+
169178
if groupBy, ok := s.D.GetOkExists("group_by"); ok {
170179
request.GroupBy = oci_data_safe.ListFindingAnalyticsGroupByEnum(groupBy.(string))
171180
}

internal/service/data_safe/data_safe_security_assessment_findings_data_source.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ func DataSafeSecurityAssessmentFindingsDataSource() *schema.Resource {
8686
Type: schema.TypeString,
8787
},
8888
},
89+
"doclink": {
90+
Type: schema.TypeString,
91+
Computed: true,
92+
},
8993
"has_target_db_risk_level_changed": {
9094
Type: schema.TypeBool,
9195
Computed: true,
@@ -140,6 +144,10 @@ func DataSafeSecurityAssessmentFindingsDataSource() *schema.Resource {
140144
Type: schema.TypeString,
141145
Computed: true,
142146
},
147+
"orp": {
148+
Type: schema.TypeString,
149+
Computed: true,
150+
},
143151
"stig": {
144152
Type: schema.TypeString,
145153
Computed: true,
@@ -310,6 +318,10 @@ func (s *DataSafeSecurityAssessmentFindingsDataSourceCrud) SetData() error {
310318
securityAssessmentFinding["details"] = nil
311319
}
312320

321+
if r.Doclink != nil {
322+
securityAssessmentFinding["doclink"] = *r.Doclink
323+
}
324+
313325
if r.HasTargetDbRiskLevelChanged != nil {
314326
securityAssessmentFinding["has_target_db_risk_level_changed"] = *r.HasTargetDbRiskLevelChanged
315327
}
@@ -403,6 +415,10 @@ func FindingsReferencesToMap(obj *oci_data_safe.References) map[string]interface
403415
result["obp"] = string(*obj.Obp)
404416
}
405417

418+
if obj.Orp != nil {
419+
result["orp"] = string(*obj.Orp)
420+
}
421+
406422
if obj.Stig != nil {
407423
result["stig"] = string(*obj.Stig)
408424
}

0 commit comments

Comments
 (0)