Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit

Permalink
refactor: update Misconfiguration field names
Browse files Browse the repository at this point in the history
Signed-off-by: András Jáky <[email protected]>
  • Loading branch information
akijakya committed Feb 8, 2024
1 parent 1ea771d commit ec3ee24
Show file tree
Hide file tree
Showing 13 changed files with 644 additions and 644 deletions.
34 changes: 17 additions & 17 deletions api/server/database/gorm/odata.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,14 @@ var schemaMetas = map[string]odatasql.SchemaMeta{
},
"Misconfiguration": {
Fields: odatasql.Schema{
"scannerName": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"scannedPath": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"testCategory": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"testID": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"testDescription": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"severity": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"message": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"remediation": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"scannerName": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"location": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"category": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"id": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"description": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"severity": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"message": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"remediation": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
},
},
"RootkitScan": {
Expand Down Expand Up @@ -985,15 +985,15 @@ var schemaMetas = map[string]odatasql.SchemaMeta{
},
"MisconfigurationFindingInfo": {
Fields: odatasql.Schema{
"objectType": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"scannerName": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"scannedPath": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"testCategory": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"testID": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"testDescription": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"severity": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"message": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"remediation": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"objectType": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"scannerName": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"location": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"category": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"id": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"description": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"severity": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"message": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
"remediation": odatasql.FieldMeta{FieldType: odatasql.StringFieldType},
},
},
"InfoFinderFindingInfo": {
Expand Down
32 changes: 16 additions & 16 deletions cli/families/misconfiguration/fake/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,44 +55,44 @@ func (a *Scanner) Run(sourceType utils.SourceType, userInput string) error {
func createFakeMisconfigurationReport() []misconfigurationTypes.Misconfiguration {
return []misconfigurationTypes.Misconfiguration{
{
ScannedPath: "/fake",
Location: "/fake",

TestCategory: "FAKE",
TestID: "Test1",
TestDescription: "Fake test number 1",
Category: "FAKE",
ID: "Test1",
Description: "Fake test number 1",

Message: "Fake test number 1 failed",
Severity: misconfigurationTypes.HighSeverity,
Remediation: "fix the thing number 1",
},
{
ScannedPath: "/fake",
Location: "/fake",

TestCategory: "FAKE",
TestID: "Test2",
TestDescription: "Fake test number 2",
Category: "FAKE",
ID: "Test2",
Description: "Fake test number 2",

Message: "Fake test number 2 failed",
Severity: misconfigurationTypes.LowSeverity,
Remediation: "fix the thing number 2",
},
{
ScannedPath: "/fake",
Location: "/fake",

TestCategory: "FAKE",
TestID: "Test3",
TestDescription: "Fake test number 3",
Category: "FAKE",
ID: "Test3",
Description: "Fake test number 3",

Message: "Fake test number 3 failed",
Severity: misconfigurationTypes.MediumSeverity,
Remediation: "fix the thing number 3",
},
{
ScannedPath: "/fake",
Location: "/fake",

TestCategory: "FAKE",
TestID: "Test4",
TestDescription: "Fake test number 4",
Category: "FAKE",
ID: "Test4",
Description: "Fake test number 4",

Message: "Fake test number 4 failed",
Severity: misconfigurationTypes.HighSeverity,
Expand Down
2 changes: 1 addition & 1 deletion cli/families/misconfiguration/family.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (m Misconfiguration) Run(ctx context.Context, _ *results.Results) (interfac
// StripPathFromResult strip input path from results wherever it is found.
func StripPathFromResult(result misconfigurationTypes.ScannerResult, path string) misconfigurationTypes.ScannerResult {
for i := range result.Misconfigurations {
result.Misconfigurations[i].ScannedPath = familiesutils.TrimMountPath(result.Misconfigurations[i].ScannedPath, path)
result.Misconfigurations[i].Location = familiesutils.TrimMountPath(result.Misconfigurations[i].Location, path)
}
return result
}
Expand Down
48 changes: 24 additions & 24 deletions cli/families/misconfiguration/family_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@ func TestStripPathFromResult(t *testing.T) {
ScannerName: "scanner1",
Misconfigurations: []types.Misconfiguration{
{
ScannedPath: "/mnt/foo",
TestCategory: "test1",
TestID: "id1",
TestDescription: "desc1",
Location: "/mnt/foo",
Category: "test1",
ID: "id1",
Description: "desc1",
},
{
ScannedPath: "/mnt/foo2",
TestCategory: "test2",
TestID: "id2",
TestDescription: "desc2",
Location: "/mnt/foo2",
Category: "test2",
ID: "id2",
Description: "desc2",
},
{
ScannedPath: "/foo3",
TestCategory: "test3",
TestID: "id3",
TestDescription: "desc3",
Location: "/foo3",
Category: "test3",
ID: "id3",
Description: "desc3",
},
},
},
Expand All @@ -64,22 +64,22 @@ func TestStripPathFromResult(t *testing.T) {
ScannerName: "scanner1",
Misconfigurations: []types.Misconfiguration{
{
ScannedPath: "/foo",
TestCategory: "test1",
TestID: "id1",
TestDescription: "desc1",
Location: "/foo",
Category: "test1",
ID: "id1",
Description: "desc1",
},
{
ScannedPath: "/foo2",
TestCategory: "test2",
TestID: "id2",
TestDescription: "desc2",
Location: "/foo2",
Category: "test2",
ID: "id2",
Description: "desc2",
},
{
ScannedPath: "/foo3",
TestCategory: "test3",
TestID: "id3",
TestDescription: "desc3",
Location: "/foo3",
Category: "test3",
ID: "id3",
Description: "desc3",
},
},
},
Expand Down
16 changes: 8 additions & 8 deletions cli/families/misconfiguration/lynis/reportParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (a *ReportParser) parseLynisReportLine(scanPath string, line string) (bool,

// LYNIS suggestions are about the lynis install itself, we
// should ignore these.
if mis.TestID == "LYNIS" {
if mis.ID == "LYNIS" {
return false, types.Misconfiguration{}, nil
}

Expand Down Expand Up @@ -132,12 +132,12 @@ func (a *ReportParser) valueToMisconfiguration(scanPath string, value string, se
message := fmt.Sprintf("%s Details: %s", parts[1], parts[2])

return types.Misconfiguration{
ScannedPath: scanPath,
TestCategory: a.testdb.GetCategoryForTestID(parts[0]),
TestID: parts[0],
TestDescription: a.testdb.GetDescriptionForTestID(parts[0]),
Severity: severity,
Message: message,
Remediation: parts[3],
Location: scanPath,
Category: a.testdb.GetCategoryForTestID(parts[0]),
ID: parts[0],
Description: a.testdb.GetDescriptionForTestID(parts[0]),
Severity: severity,
Message: message,
Remediation: parts[3],
}, nil
}
Loading

0 comments on commit ec3ee24

Please sign in to comment.