Skip to content

Commit

Permalink
[CWS] Move JSON schemas to secl package (#30913)
Browse files Browse the repository at this point in the history
  • Loading branch information
lebauce authored Nov 18, 2024
1 parent 44cf7cf commit 3387a1b
Show file tree
Hide file tree
Showing 57 changed files with 334 additions and 323 deletions.
2 changes: 1 addition & 1 deletion pkg/security/generators/schemas/policy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2016-present Datadog, Inc.

//go:generate go run github.com/DataDog/datadog-agent/pkg/security/generators/schemas/policy -output ../../../tests/schemas/policy.schema.json
//go:generate go run github.com/DataDog/datadog-agent/pkg/security/generators/schemas/policy -output ../../../secl/schemas/policy.schema.json

// Package main holds main related files
package main
Expand Down
2 changes: 1 addition & 1 deletion pkg/security/secl/rules/policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ func TestPolicySchema(t *testing.T) {
},
}

fs := os.DirFS("../../../../pkg/security/tests/schemas")
fs := os.DirFS("../../../../pkg/security/secl/schemas")
schemaLoader := gojsonschema.NewReferenceLoaderFileSystem("file:///policy.schema.json", http.FS(fs))

for _, test := range tests {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "agent_context.json",
"$id": "agent_context.schema.json",
"type": "object",
"properties": {
"rule_id": {
Expand Down Expand Up @@ -32,10 +32,10 @@
"items": {
"oneOf": [
{
"$ref": "/schemas/kill.schema.json"
"$ref": "kill.schema.json"
},
{
"$ref": "/schemas/hash.schema.json"
"$ref": "hash.schema.json"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "bind.json",
"$id": "bind.schema.json",
"type": "object",
"allOf": [
{
"$ref": "/schemas/event.json"
"$ref": "event.schema.json"
},
{
"$ref": "/schemas/usr.json"
"$ref": "usr.schema.json"
},
{
"$ref": "/schemas/process_context.json"
"$ref": "process_context.schema.json"
},
{
"date": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "bpf.json",
"$id": "bpf.schema.json",
"type": "object",
"allOf": [
{
"$ref": "/schemas/event.json"
"$ref": "event.schema.json"
},
{
"$ref": "/schemas/usr.json"
"$ref": "usr.schema.json"
},
{
"$ref": "/schemas/process_context.json"
"$ref": "process_context.schema.json"
},
{
"date": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "chmod.json",
"$id": "chmod.schema.json",
"type": "object",
"anyOf": [
{
"$ref": "/schemas/container_event.json"
"$ref": "container_event.schema.json"
},
{
"$ref": "/schemas/host_event.json"
"$ref": "host_event.schema.json"
}
],
"allOf": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "chown.json",
"$id": "chown.schema.json",
"type": "object",
"anyOf": [
{
"$ref": "/schemas/container_event.json"
"$ref": "container_event.schema.json"
},
{
"$ref": "/schemas/host_event.json"
"$ref": "host_event.schema.json"
}
],
"allOf": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "connect.json",
"$id": "connect.schema.json",
"type": "object",
"allOf": [
{
"$ref": "/schemas/event.json"
"$ref": "event.schema.json"
},
{
"$ref": "/schemas/usr.json"
"$ref": "usr.schema.json"
},
{
"$ref": "/schemas/process_context.json"
"$ref": "process_context.schema.json"
},
{
"date": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "container.json",
"$id": "container.schema.json",
"type": "object",
"properties": {
"id": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "container_context.json",
"$id": "container_context.schema.json",
"type": "object",
"properties": {
"container": {
"$ref": "/schemas/container.json"
"$ref": "container.schema.json"
}
},
"required": [
Expand Down
12 changes: 12 additions & 0 deletions pkg/security/secl/schemas/container_event.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "container_event.schema.json",
"allOf": [
{
"$ref": "host_event.schema.json"
},
{
"$ref": "container_context.schema.json"
}
]
}
12 changes: 12 additions & 0 deletions pkg/security/secl/schemas/container_event_no_file.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "container_event_no_file.schema.json",
"allOf": [
{
"$ref": "host_event_no_file.schema.json"
},
{
"$ref": "container_context.schema.json"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "datetime.json",
"$id": "datetime.schema.json",
"allOf": [
{
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "dns.json",
"$id": "dns.schema.json",
"type": "object",
"allOf": [
{
"$ref": "/schemas/event.json"
"$ref": "event.schema.json"
},
{
"$ref": "/schemas/usr.json"
"$ref": "usr.schema.json"
},
{
"$ref": "/schemas/process_context.json"
"$ref": "process_context.schema.json"
},
{
"$ref": "/schemas/network.json"
"$ref": "network.schema.json"
},
{
"date": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "event.json",
"$id": "event.schema.json",
"type": "object",
"properties": {
"evt": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"type": "object"
},
"date": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "exec.json",
"$id": "exec.schema.json",
"type": "object",
"anyOf": [
{
"$ref": "/schemas/container_event.json"
"$ref": "container_event.schema.json"
},
{
"$ref": "/schemas/host_event.json"
"$ref": "host_event.schema.json"
}
],
"allOf": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "exit.json",
"$id": "exit.schema.json",
"type": "object",
"anyOf": [
{
"$ref": "/schemas/container_event.json"
"$ref": "container_event.schema.json"
},
{
"$ref": "/schemas/host_event.json"
"$ref": "host_event.schema.json"
}
],
"allOf": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "file.json",
"$id": "file.schema.json",
"type": "object",
"properties": {
"path": {
Expand Down Expand Up @@ -29,10 +29,10 @@
"type": "string"
},
"modification_time": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
},
"change_time": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
},
"flags": {
"type": "array",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "kill.json",
"$id": "kill.schema.json",
"type": "object",
"properties": {
"type": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "heartbeat.json",
"$id": "heartbeat.schema.json",
"type": "object",
"properties": {
"policy": {
Expand All @@ -9,7 +9,7 @@
}
},
"date": {
"$ref": "/schemas/datetime.json"
"$ref": "datetime.schema.json"
}
},
"required": [
Expand Down
23 changes: 23 additions & 0 deletions pkg/security/secl/schemas/host_event.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "host_event.schema.json",
"allOf": [
{
"$ref": "event.schema.json"
},
{
"file": { "$ref": "file.schema.json" }
},
{
"$ref": "usr.schema.json"
},
{
"$ref": "process_context.schema.json"
},
{
"date": {
"$ref": "datetime.schema.json"
}
}
]
}
20 changes: 20 additions & 0 deletions pkg/security/secl/schemas/host_event_no_file.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "host_event_no_file.schema.json",
"allOf": [
{
"$ref": "event.schema.json"
},
{
"$ref": "usr.schema.json"
},
{
"$ref": "process_context.schema.json"
},
{
"date": {
"$ref": "datetime.schema.json"
}
}
]
}
Loading

0 comments on commit 3387a1b

Please sign in to comment.