Skip to content

Prevent SQL Injection#16

Open
yamaceay wants to merge 1 commit intomainfrom
prevent-sql-injection
Open

Prevent SQL Injection#16
yamaceay wants to merge 1 commit intomainfrom
prevent-sql-injection

Conversation

@yamaceay
Copy link
Contributor

No description provided.

@yamaceay yamaceay force-pushed the prevent-sql-injection branch 5 times, most recently from f6e5c6b to f092b43 Compare February 19, 2026 16:06
Copy link
Member

@Noel-Ch Noel-Ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

I think it'll be better if we can review unrelated changes in a separate PR, especially if they are more complicated

Comment on lines 166 to 168
if err != nil {
// In case of error, return original actions
return actionStrings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we ignore the errors and return the original actions here, or actually return an error so that the user knows that there is a problem?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I'm switching it back.


func prepareCreateSql(parameters *v1alpha1.AuditPolicyParameters) string {
query := fmt.Sprintf("CREATE AUDIT POLICY %s AUDITING %s", parameters.PolicyName, parameters.AuditStatus)
func OptimizeAuditActions(actionStrings []string) []string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a lot of complexity added here, and it seems like the changes are not directly related to the SQL injection risk. Maybe we can handle this in a separate PR?

if _, found := set2[item]; !found {
return false
}
func MapKeysToUpper[A comparable](input map[string]A) map[string]A {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function necessary? There is a loop immediately after each use of the function. Can we do the uppercasing in that loop, so that we don't have a extra allocation of a new map?

}

return true
func MapsEqual[A comparable](map1, map2 map[string]A) bool {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove this function and use maps.Equal instead

Comment on lines 54 to 56
if len(leftDifference) != 0 || len(map1) != len(map2) {
return false, nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If isEqual is false, shouldn't we return the difference instead of nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! I remember we talked about shortcutting the isEqual output (so that we just check one difference instead of two). Then I think it's better to check both differences in either case. I will introduce a new flag to allow shortcutting.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we already know that both maps are the same, we can return early because the difference would be nil.

But if the maps are different, we have to check the maps for what is difference, and return the difference

Comment on lines 43 to 45
if len(leftDifference) != 0 || len(set1) != len(set2) {
return false, nil, nil
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If isEqual is false, shouldn't we return the difference instead of nil?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants