-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for the recommended security requirements of the container-nati…
…ve operators checks: USER id should not be 0 readOnlyRootFilesystem = true runAsNonRoot = true automount service account token = false{}
- Loading branch information
1 parent
316b89d
commit 438c545
Showing
17 changed files
with
564 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (C) 2020-2024 Red Hat, Inc. | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; either version 2 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, write to the Free Software Foundation, Inc., | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
/* | ||
Package operator provides CNFCERT tests used to validate operator CNF facets. | ||
*/ | ||
|
||
package operator | ||
|
||
import "strings" | ||
|
||
// CsvResult holds the results of the splitCsv function. | ||
type CsvResult struct { | ||
NameCsv string | ||
Namespace string | ||
} | ||
|
||
// splitCsv splits the input string to extract namecsv and namespace. | ||
func SplitCsv(csv string) CsvResult { | ||
// Split by comma to separate components | ||
parts := strings.Split(csv, ",") | ||
var result CsvResult | ||
|
||
for _, part := range parts { | ||
part = strings.TrimSpace(part) | ||
|
||
if strings.HasPrefix(part, "ns=") { | ||
result.Namespace = strings.TrimPrefix(part, "ns=") | ||
} else { | ||
result.NameCsv = part | ||
} | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (C) 2020-2024 Red Hat, Inc. | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation; either version 2 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License along | ||
// with this program; if not, write to the Free Software Foundation, Inc., | ||
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
|
||
/* | ||
Package operator provides CNFCERT tests used to validate operator CNF facets. | ||
*/ | ||
|
||
package operator | ||
|
||
import "testing" | ||
|
||
func TestSplitCsv(t *testing.T) { | ||
tests := []struct { | ||
input string | ||
expectedCsv string | ||
expectedNs string | ||
}{ | ||
{ | ||
input: "hazelcast-platform-operator.v5.12.0, ns=tnf", | ||
expectedCsv: "hazelcast-platform-operator.v5.12.0", | ||
expectedNs: "tnf", | ||
}, | ||
{ | ||
input: "example-operator.v1.0.0, ns=example-ns", | ||
expectedCsv: "example-operator.v1.0.0", | ||
expectedNs: "example-ns", | ||
}, | ||
{ | ||
input: "another-operator.v2.3.1, ns=another-ns", | ||
expectedCsv: "another-operator.v2.3.1", | ||
expectedNs: "another-ns", | ||
}, | ||
{ | ||
input: "no-namespace", | ||
expectedCsv: "no-namespace", | ||
expectedNs: "", | ||
}, | ||
{ | ||
input: "ns=onlynamespace", | ||
expectedCsv: "", | ||
expectedNs: "onlynamespace", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.input, func(t *testing.T) { | ||
result := SplitCsv(tt.input) | ||
if result.NameCsv != tt.expectedCsv { | ||
t.Errorf("splitCsv(%q) got namecsv %q, want %q", tt.input, result.NameCsv, tt.expectedCsv) | ||
} | ||
if result.Namespace != tt.expectedNs { | ||
t.Errorf("splitCsv(%q) got namespace %q, want %q", tt.input, result.Namespace, tt.expectedNs) | ||
} | ||
}) | ||
} | ||
} |
Oops, something went wrong.