Skip to content

Commit 28fbc66

Browse files
authored
feat: Add IDs to Signature Metadata. (#567)
1 parent 05b0d91 commit 28fbc66

24 files changed

+133
-33
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Name | Description | Tags
5151
Standard Input/Output Over Socket | Redirection of process's standard input/output to socket | "linux", "container"
5252
Anti-Debugging | Process uses anti-debugging technique to block debugger | "linux", "container"
5353
Code injection | Possible code injection into another process | "linux", "container"
54-
Dynamic Code Loading | writing to executable allocated memory region | "linux", "container"
54+
Dynamic Code Loading | Writing to executable allocated memory region | "linux", "container"
5555
Fileless Execution | Executing a precess from memory, without a file in the disk | "linux", "container"
5656
kernel module loading | Attempt to load a kernel module detection | "linux", "container"
5757
LD_PRELOAD | Usage of LD_PRELOAD to allow hooks on process | "linux", "container"

tracee-rules/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ func main() {
2828
return err
2929
}
3030
if c.Bool("list") {
31-
fmt.Printf("%-30s %s\n", "RULE NAME", "DESCRIPTION")
31+
fmt.Printf("%-10s %-35s %s\n", "ID", "NAME", "DESCRIPTION")
3232
for _, sig := range sigs {
3333
meta, err := sig.GetMetadata()
3434
if err != nil {
3535
continue
3636
}
37-
fmt.Printf("%-30s %s\n", meta.Name, meta.Description)
37+
fmt.Printf("%-10s %-35s %s\n", meta.ID, meta.Name, meta.Description)
3838
}
3939
return nil
4040
}

tracee-rules/signature.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func getSignatures(rulesDir string, rules []string) ([]types.Signature, error) {
3535
} else {
3636
for _, s := range sigs {
3737
for _, r := range rules {
38-
if m, err := s.GetMetadata(); err == nil && m.Name == r {
38+
if m, err := s.GetMetadata(); err == nil && m.ID == r {
3939
res = append(res, s)
4040
}
4141
}

tracee-rules/signature_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"encoding/json"
5+
"testing"
6+
7+
"github.com/aquasecurity/tracee/tracee-rules/types"
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func Test_getSignatures(t *testing.T) {
13+
sigs, err := getSignatures("signatures/rego", []string{"TRC-2"})
14+
require.NoError(t, err)
15+
require.Equal(t, 1, len(sigs))
16+
17+
gotMetadata, err := sigs[0].GetMetadata()
18+
assert.Equal(t, types.SignatureMetadata{
19+
ID: "TRC-2",
20+
Name: "Anti-Debugging",
21+
Description: "Process uses anti-debugging technique to block debugger",
22+
Tags: []string{"linux", "container"},
23+
Properties: map[string]interface{}{
24+
"MITRE ATT&CK": "Defense Evasion: Execution Guardrails",
25+
"Severity": json.Number("3"),
26+
},
27+
}, gotMetadata)
28+
}

tracee-rules/signatures/golang/stdio_over_socket.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"fmt"
5+
56
tracee "github.com/aquasecurity/tracee/tracee-ebpf/tracee/external"
67
"github.com/aquasecurity/tracee/tracee-rules/types"
78
)
@@ -20,6 +21,7 @@ func (sig *stdioOverSocket) Init(cb types.SignatureHandler) error {
2021

2122
func (sig *stdioOverSocket) GetMetadata() (types.SignatureMetadata, error) {
2223
return types.SignatureMetadata{
24+
ID: "TRC-1",
2325
Name: "Standard Input/Output Over Socket",
2426
Description: "Redirection of process's standard input/output to socket",
2527
Tags: []string{"linux", "container"},

tracee-rules/signatures/rego/anti_debugging_ptraceme.rego

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package main
1+
package tracee.TRC_2
22

33
__rego_metadoc__ := {
4+
"id": "TRC-2",
45
"name": "Anti-Debugging",
56
"description": "Process uses anti-debugging technique to block debugger",
67
"tags": ["linux", "container"],

tracee-rules/signatures/rego/anti_debugging_ptraceme_test.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package tracee.TRC_2
22

33
test_match_1 {
44
tracee_match with input as {

tracee-rules/signatures/rego/code_injection.rego

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
package main
1+
package tracee.TRC_3
22

33
import data.tracee.helpers
44

55
__rego_metadoc__ := {
6+
"id": "TRC-3",
67
"name": "Code injection",
78
"description": "Possible code injection into another process",
89
"tags": ["linux", "container"],

tracee-rules/signatures/rego/code_injection_test.rego

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package tracee.TRC_3
22

33
test_match_1 {
44
tracee_match with input as {

tracee-rules/signatures/rego/dynamic_code_loading.rego

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package main
1+
package tracee.TRC_4
22

33
import data.tracee.helpers
44

55
__rego_metadoc__ := {
6+
"id": "TRC-4",
67
"name": "Dynamic Code Loading",
7-
"description": "writing to executable allocated memory region",
8+
"description": "Writing to executable allocated memory region",
89
"tags": ["linux", "container"],
910
"properties": {
1011
"Severity": 2,

0 commit comments

Comments
 (0)