From 67c9771101590093c0e07e3372badb9caeae67da Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Fri, 13 Jan 2023 10:12:39 +0100 Subject: [PATCH 1/3] 5.19 -> 6.1 --- pkg/security/secl/model/syscalls.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/security/secl/model/syscalls.go b/pkg/security/secl/model/syscalls.go index ca1bd51451a64..eaec6e4f6b953 100644 --- a/pkg/security/secl/model/syscalls.go +++ b/pkg/security/secl/model/syscalls.go @@ -6,8 +6,8 @@ //go:build linux // +build linux -//go:generate go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url https://raw.githubusercontent.com/torvalds/linux/v5.19/arch/x86/entry/syscalls/syscall_64.tbl -output syscalls_linux_amd64.go -output-string syscalls_string_linux_amd64.go -abis common,64 -//go:generate go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url https://raw.githubusercontent.com/torvalds/linux/v5.19/include/uapi/asm-generic/unistd.h -output syscalls_linux_arm64.go -output-string syscalls_string_linux_arm64.go +//go:generate go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url https://raw.githubusercontent.com/torvalds/linux/v6.1/arch/x86/entry/syscalls/syscall_64.tbl -output syscalls_linux_amd64.go -output-string syscalls_string_linux_amd64.go -abis common,64 +//go:generate go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url https://raw.githubusercontent.com/torvalds/linux/v6.1/include/uapi/asm-generic/unistd.h -output syscalls_linux_arm64.go -output-string syscalls_string_linux_arm64.go package model From 3e39866f272b349598a7e1ef0146cc92b9b6be44 Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Fri, 13 Jan 2023 10:19:52 +0100 Subject: [PATCH 2/3] switch syscall table generator from go generate to task --- pkg/security/secl/model/syscalls.go | 3 --- .../secl/model/syscalls_string_linux_amd64.go | 2 +- .../secl/model/syscalls_string_linux_arm64.go | 2 +- tasks/security_agent.py | 24 +++++++++++++++++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/pkg/security/secl/model/syscalls.go b/pkg/security/secl/model/syscalls.go index eaec6e4f6b953..59007c7629286 100644 --- a/pkg/security/secl/model/syscalls.go +++ b/pkg/security/secl/model/syscalls.go @@ -6,9 +6,6 @@ //go:build linux // +build linux -//go:generate go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url https://raw.githubusercontent.com/torvalds/linux/v6.1/arch/x86/entry/syscalls/syscall_64.tbl -output syscalls_linux_amd64.go -output-string syscalls_string_linux_amd64.go -abis common,64 -//go:generate go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url https://raw.githubusercontent.com/torvalds/linux/v6.1/include/uapi/asm-generic/unistd.h -output syscalls_linux_arm64.go -output-string syscalls_string_linux_arm64.go - package model import ( diff --git a/pkg/security/secl/model/syscalls_string_linux_amd64.go b/pkg/security/secl/model/syscalls_string_linux_amd64.go index 5b32b64f8a568..39b70b17150cf 100644 --- a/pkg/security/secl/model/syscalls_string_linux_amd64.go +++ b/pkg/security/secl/model/syscalls_string_linux_amd64.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type Syscall -output syscalls_string_linux_amd64.go syscalls_linux_amd64.go"; DO NOT EDIT. +// Code generated by "stringer -type Syscall -output pkg/security/secl/model/syscalls_string_linux_amd64.go pkg/security/secl/model/syscalls_linux_amd64.go"; DO NOT EDIT. package model diff --git a/pkg/security/secl/model/syscalls_string_linux_arm64.go b/pkg/security/secl/model/syscalls_string_linux_arm64.go index 54fa94f312bd9..1d2f5c941ecda 100644 --- a/pkg/security/secl/model/syscalls_string_linux_arm64.go +++ b/pkg/security/secl/model/syscalls_string_linux_arm64.go @@ -1,4 +1,4 @@ -// Code generated by "stringer -type Syscall -output syscalls_string_linux_arm64.go syscalls_linux_arm64.go"; DO NOT EDIT. +// Code generated by "stringer -type Syscall -output pkg/security/secl/model/syscalls_string_linux_arm64.go pkg/security/secl/model/syscalls_linux_arm64.go"; DO NOT EDIT. package model diff --git a/tasks/security_agent.py b/tasks/security_agent.py index d290c8abd766b..a4cbb5201427f 100644 --- a/tasks/security_agent.py +++ b/tasks/security_agent.py @@ -567,6 +567,30 @@ def cws_go_generate(ctx): ctx.run("go generate ./pkg/security/...") +@task +def generate_syscall_table(ctx): + def single_run(ctx, table_url, output_file, output_string_file, abis=None): + if abis: + abis = f"-abis {abis}" + ctx.run( + f"go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url {table_url} -output {output_file} -output-string {output_string_file} {abis}" + ) + + single_run( + ctx, + "https://raw.githubusercontent.com/torvalds/linux/v6.1/arch/x86/entry/syscalls/syscall_64.tbl", + "pkg/security/secl/model/syscalls_linux_amd64.go", + "pkg/security/secl/model/syscalls_string_linux_amd64.go", + abis="common,64", + ) + single_run( + ctx, + "https://raw.githubusercontent.com/torvalds/linux/v6.1/include/uapi/asm-generic/unistd.h", + "pkg/security/secl/model/syscalls_linux_arm64.go", + "pkg/security/secl/model/syscalls_string_linux_arm64.go", + ) + + @task def generate_btfhub_constants(ctx, archive_path, force_refresh=False): output_path = "./pkg/security/probe/constantfetch/btfhub/constants.json" From 0eda72058b1d9c07aa2c0f0f62b0f5790f0887ea Mon Sep 17 00:00:00 2001 From: Paul Cacheux Date: Fri, 13 Jan 2023 10:23:16 +0100 Subject: [PATCH 3/3] extract linux version --- tasks/security_agent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/security_agent.py b/tasks/security_agent.py index a4cbb5201427f..cdc50fac75b49 100644 --- a/tasks/security_agent.py +++ b/tasks/security_agent.py @@ -576,16 +576,17 @@ def single_run(ctx, table_url, output_file, output_string_file, abis=None): f"go run github.com/DataDog/datadog-agent/pkg/security/secl/model/syscall_table_generator -table-url {table_url} -output {output_file} -output-string {output_string_file} {abis}" ) + linux_version = "v6.1" single_run( ctx, - "https://raw.githubusercontent.com/torvalds/linux/v6.1/arch/x86/entry/syscalls/syscall_64.tbl", + f"https://raw.githubusercontent.com/torvalds/linux/{linux_version}/arch/x86/entry/syscalls/syscall_64.tbl", "pkg/security/secl/model/syscalls_linux_amd64.go", "pkg/security/secl/model/syscalls_string_linux_amd64.go", abis="common,64", ) single_run( ctx, - "https://raw.githubusercontent.com/torvalds/linux/v6.1/include/uapi/asm-generic/unistd.h", + f"https://raw.githubusercontent.com/torvalds/linux/{linux_version}/include/uapi/asm-generic/unistd.h", "pkg/security/secl/model/syscalls_linux_arm64.go", "pkg/security/secl/model/syscalls_string_linux_arm64.go", )