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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CSPM exception policy type and related attributes #431

Merged
merged 1 commit into from
Jan 22, 2025
Merged

Conversation

kooomix
Copy link
Contributor

@kooomix kooomix commented Jan 22, 2025

PR Type

Enhancement


Description

  • Introduced a new CSPMExceptionPolicy type with relevant attributes.

  • Added CSPMExceptionPolicyType constant for CSPM exception policies.

  • Included a new AttributeAccount identifier for account-related attributes.


Changes walkthrough 📝

Relevant files
Enhancement
cloudposturetypes.go
Introduced `CSPMExceptionPolicy` struct for CSPM exceptions

armotypes/cloudposturetypes.go

  • Added a new struct CSPMExceptionPolicy with attributes like Name,
    Controls, Severity, etc.
  • Enhanced support for CSPM exception policies.
  • +9/-0     
    exceptionpolicy.go
    Added `CSPMExceptionPolicyType` constant for CSPM policies

    armotypes/exceptionpolicy.go

  • Added a new constant CSPMExceptionPolicyType for CSPM exception
    policies.
  • Enhanced policy type definitions to include CSPM.
  • +3/-0     
    designators.go
    Added `AttributeAccount` identifier for account attributes

    identifiers/designators.go

  • Introduced a new identifier AttributeAccount for account-related
    attributes.
  • Enhanced attribute definitions for better account handling.
  • +1/-0     

    Need help?
  • Type /help how to ... in the comments thread for any question about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Input Validation

    The CSPMExceptionPolicy struct lacks validation for required fields and potential constraints on severity values and scores. Consider adding validation or documentation for acceptable values.

    type CSPMExceptionPolicy struct {
    	BaseExceptionPolicy `json:",inline"`
    	Name                string   `json:"name"`     // rule name
    	Controls            []string `json:"controls"` // affected controls
    	Severity            string   `json:"severity"`
    	SeverityScore       int      `json:"severityScore"`
    	RuleHash            string   `json:"ruleHash"`
    }

    Copy link

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    General
    Add severity field validation

    Add validation constraints for the severity field to ensure it only accepts valid
    severity levels. This prevents potential issues with invalid severity values.

    armotypes/cloudposturetypes.go [103-110]

     type CSPMExceptionPolicy struct {
         BaseExceptionPolicy `json:",inline"`
         Name                string   `json:"name"`     // rule name
         Controls            []string `json:"controls"` // affected controls
    -    Severity            string   `json:"severity"`
    +    Severity            string   `json:"severity" validate:"oneof=low medium high critical"` 
         SeverityScore       int      `json:"severityScore"`
         RuleHash            string   `json:"ruleHash"`
     }
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding validation constraints for the severity field is a valuable improvement that prevents potential runtime issues by ensuring only valid severity levels are accepted. This enhances data integrity and reduces potential bugs.

    7

    @kooomix kooomix merged commit c73f6cc into main Jan 22, 2025
    3 checks passed
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants