Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pluralize category groups #196

Merged
merged 1 commit into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions integration/flags/.snapshots/TestInitCommand-init
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ scan:
not location.encrypted

item := {
"category_group": data.bearer.common.groups_for_datatype(datatype),
"category_groups": data.bearer.common.groups_for_datatype(datatype),
"severity": data.bearer.common.severity_of_datatype(datatype),
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -457,7 +457,7 @@ scan:

location = data_type.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": data.bearer.common.severity_of_datatype(data_type),
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -535,7 +535,7 @@ scan:

location = detector.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -613,7 +613,7 @@ scan:

location = detector.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -691,7 +691,7 @@ scan:

location = detector.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"line_number": location.line_number,
"parent_line_number": location.parent.line_number,
Expand Down Expand Up @@ -767,7 +767,7 @@ scan:

location = data_type.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": data.bearer.common.severity_of_datatype(data_type),
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -844,7 +844,7 @@ scan:

location = data_type.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": data.bearer.common.severity_of_datatype(data_type),
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -921,7 +921,7 @@ scan:

location = data_type.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": data.bearer.common.severity_of_datatype(data_type),
"filename": location.filename,
"line_number": location.line_number,
Expand Down Expand Up @@ -999,7 +999,7 @@ scan:
location = detector.locations[_]

item = {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"filename": location.filename,
"line_number": location.line_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ high:
policy_description: Logger leaks detected
line_number: 1
filename: testdata/policies/users.rb
category_group:
category_groups:
- PII
parent_line_number: 1
parent_content: logger.info(user.address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ critical:
policy_description: Sending data as HTTP GET parameters
line_number: 1
filename: testdata/ruby/http_get_parameters.rb
category_group:
category_groups:
- PII
- Sensitive data
parent_line_number: 1
Expand All @@ -13,7 +13,7 @@ high:
policy_description: Sending data as HTTP GET parameters
line_number: 4
filename: testdata/ruby/http_get_parameters.rb
category_group:
category_groups:
- PII
parent_line_number: 5
parent_content: URI.encode_www_form(user)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ medium:
policy_description: Insecure communication in an application processing sensitive data
line_number: 8
filename: testdata/ruby/insecure_communication/with_sensitive_data.rb
category_group:
category_groups:
- PII
- Sensitive data
parent_line_number: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ medium:
policy_description: Communication with insecure FTP in an application processing sensitive data
line_number: 10
filename: testdata/ruby/insecure_ftp/with_sensitive_data.rb
category_group:
category_groups:
- PII
- Sensitive data
parent_line_number: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ medium:
- policy_name: Insecure SMTP
policy_description: Communication with insecure SMTP in an application processing sensitive data
line_number: 8
category_group:
category_groups:
- PII
- Sensitive data
parent_line_number: 1
Expand Down Expand Up @@ -41,7 +41,7 @@ medium:
- policy_name: Insecure SMTP
policy_description: Communication with insecure SMTP in an application processing sensitive data
line_number: 14
category_group:
category_groups:
- PII
- Sensitive data
parent_line_number: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ high:
policy_description: Logger leaks detected
line_number: 1
filename: testdata/ruby/logger_leaking.rb
category_group:
category_groups:
- PII
parent_line_number: 1
parent_content: logger.info(user.address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ policy_breach contains item if {
not location.encrypted

item := {
"category_group": data.bearer.common.groups_for_datatype(datatype),
"category_groups": data.bearer.common.groups_for_datatype(datatype),
"severity": data.bearer.common.severity_of_datatype(datatype),
"filename": location.filename,
"line_number": location.line_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ policy_breach contains item if {

location = data_type.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": data.bearer.common.severity_of_datatype(data_type),
"filename": location.filename,
"line_number": location.line_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ policy_breach contains item if {

location = detector.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"filename": location.filename,
"line_number": location.line_number,
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/process/settings/policies/insecure_ftp.rego
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ policy_breach[item] {

location = detector.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"filename": location.filename,
"line_number": location.line_number,
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/process/settings/policies/insecure_smtp.rego
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ policy_breach contains item if {

location = detector.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"line_number": location.line_number,
"parent_line_number": location.parent.line_number,
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/process/settings/policies/leakage.rego
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ policy_breach contains item if {

location = data_type.locations[_]
item := {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": data.bearer.common.severity_of_datatype(data_type),
"filename": location.filename,
"line_number": location.line_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ policy_breach contains item if {
location = detector.locations[_]

item = {
"category_group": data.bearer.common.groups_for_datatype(data_type),
"category_groups": data.bearer.common.groups_for_datatype(data_type),
"severity": "medium",
"filename": location.filename,
"line_number": location.line_number,
Expand Down
8 changes: 4 additions & 4 deletions pkg/report/output/policies/policies.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type PolicyOutput struct {
ParentContent string `json:"parent_content,omitempty" yaml:"parent_content,omitempty"`
LineNumber int `json:"line_number,omitempty" yaml:"line_number,omitempty"`
Filename string `json:"filename,omitempty" yaml:"filename,omitempty"`
CategoryGroup []string `json:"category_group,omitempty" yaml:"category_group,omitempty"`
CategoryGroups []string `json:"category_groups,omitempty" yaml:"category_groups,omitempty"`
Severity string `json:"severity,omitempty" yaml:"severity,omitempty"`
}

Expand All @@ -42,7 +42,7 @@ type PolicyResult struct {
PolicyDescription string `json:"policy_description" yaml:"policy_description"`
LineNumber int `json:"line_number,omitempty" yaml:"line_number,omitempty"`
Filename string `json:"filename,omitempty" yaml:"filename,omitempty"`
CategoryGroup []string `json:"category_group,omitempty" yaml:"category_group,omitempty"`
CategoryGroups []string `json:"category_groups,omitempty" yaml:"category_groups,omitempty"`
ParentLineNumber int `json:"parent_line_number,omitempty" yaml:"parent_line_number,omitempty"`
ParentContent string `json:"parent_content,omitempty" yaml:"parent_content,omitempty"`
}
Expand Down Expand Up @@ -82,7 +82,7 @@ func GetOutput(dataflow *dataflow.DataFlow, config settings.Config) (map[string]
PolicyDescription: policy.Description,
Filename: policyOutput.Filename,
LineNumber: policyOutput.LineNumber,
CategoryGroup: policyOutput.CategoryGroup,
CategoryGroups: policyOutput.CategoryGroups,
ParentLineNumber: policyOutput.ParentLineNumber,
ParentContent: policyOutput.ParentContent,
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func writeSummaryToString(
func writePolicyBreachToString(reportStr *strings.Builder, policyBreach PolicyResult, policySeverity string) {
reportStr.WriteString("\n\n")
reportStr.WriteString(formatSeverity(policySeverity))
reportStr.WriteString(policyBreach.PolicyName + " policy breach with " + strings.Join(policyBreach.CategoryGroup, ", ") + "\n")
reportStr.WriteString(policyBreach.PolicyName + " policy breach with " + strings.Join(policyBreach.CategoryGroups, ", ") + "\n")
reportStr.WriteString(color.HiBlackString(policyBreach.PolicyDescription + "\n"))
reportStr.WriteString("\n")
reportStr.WriteString(color.HiBlueString("File: " + underline(policyBreach.Filename+":"+fmt.Sprint(policyBreach.LineNumber)) + "\n"))
Expand Down