Skip to content

Commit

Permalink
add group ID in expanded rule ID
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed Dec 20, 2024
1 parent 82d76fe commit 8809771
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/security/secl/rules/fim_others.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type expandedRule struct {
expr string
}

func expandFim(baseID, baseExpr string) []expandedRule {
func expandFim(baseID, groupID, baseExpr string) []expandedRule {
return []expandedRule{
{
id: baseID,
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/secl/rules/fim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func TestExpandFIM(t *testing.T) {

for _, entry := range entries {
t.Run(entry.id, func(t *testing.T) {
actual := expandFim(entry.id, entry.expr)
actual := expandFim(entry.id, "", entry.expr)
assert.Equal(t, entry.expected, actual)
})
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/security/secl/rules/fim_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type expandedRule struct {
expr string
}

func expandFim(baseID, baseExpr string) []expandedRule {
func expandFim(baseID, groupID, baseExpr string) []expandedRule {
if !strings.Contains(baseExpr, "fim.write.file.") {
return []expandedRule{
{
Expand All @@ -43,7 +43,7 @@ func expandFim(baseID, baseExpr string) []expandedRule {

if eventType == "rename" {
expr := strings.Replace(baseExpr, "fim.write.file.", "rename.file.destination.", -1)
id := fmt.Sprintf("__fim_expanded_%s_%s", "rename_destination", baseID)
id := fmt.Sprintf("__fim_expanded_%s_%s_%s", "rename_destination", groupdID, baseID)
expandedRules = append(expandedRules, expandedRule{
id: id,
expr: expr,
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/secl/rules/ruleset.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func (rs *RuleSet) AddRule(parsingContext *ast.ParsingContext, pRule *PolicyRule
tags = append(tags, k+":"+v)
}

expandedRules := expandFim(pRule.Def.ID, pRule.Def.Expression)
expandedRules := expandFim(pRule.Def.ID, pRule.Def.GroupID, pRule.Def.Expression)

categories := make([]model.EventCategory, 0)
for _, er := range expandedRules {
Expand Down

0 comments on commit 8809771

Please sign in to comment.