-
Notifications
You must be signed in to change notification settings - Fork 464
internal/appsec: rework appsec telemetry #3345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Datadog ReportBranch report: ✅ 0 Failed, 4472 Passed, 65 Skipped, 3m 37.58s Total Time |
BenchmarksBenchmark execution time: 2025-04-10 09:03:21 Comparing candidate commit 83a543f in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 55 metrics, 1 unstable metrics. |
5c6ec98
to
57ea557
Compare
Signed-off-by: Eliott Bouhana <[email protected]>
Signed-off-by: Eliott Bouhana <[email protected]>
Signed-off-by: Eliott Bouhana <[email protected]>
57ea557
to
a3b5339
Compare
RASPRuleTypeSSRF RASPRuleType = "ssrf" | ||
RASPRuleTypeSQLI RASPRuleType = "sql_injection" | ||
RASPRuleTypeCMDI RASPRuleType = "command_injection" | ||
RASPRuleTypeLFI RASPRuleType = iota |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest making the 0-value invalid:
RASPRuleTypeLFI RASPRuleType = iota | |
_ RASPRuleType = iota | |
RASPRuleTypeLFI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would make my for loops wrong because I loop on them like a dictionnary but they are arrays 😭
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
// RASPRuleTypeFromAddressSet returns the RASPRuleType for the given address set if it has a RASP address. | ||
func RASPRuleTypeFromAddressSet(addressSet waf.RunAddressData) (RASPRuleType, bool) { | ||
if addressSet.Scope != waf.RASPScope { | ||
return "", false | ||
return math.MaxUint8, false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the 0-value is invalid, you could return 0 instead, which looks less weird?
@@ -46,5 +60,5 @@ func RASPRuleTypeFromAddressSet(addressSet waf.RunAddressData) (RASPRuleType, bo | |||
} | |||
} | |||
|
|||
return "", false | |||
return math.MaxUint8, false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the 0-value is invalid, you could return 0 instead, which looks less weird?
@@ -24,6 +24,8 @@ import ( | |||
"github.com/DataDog/appsec-internal-go/apisec" | |||
"github.com/stretchr/testify/assert" | |||
|
|||
"github.com/stretchr/testify/mock" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this seems unrelated... And the blank spacing there is odd... I'd normalize it or not touch it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was indeed wrong regarding import order so I fixed it even more
Signed-off-by: Eliott Bouhana <[email protected]>
Signed-off-by: Eliott Bouhana <[email protected]>
What does this PR do?
rasp.timeout
metric.RASPRuleType
type from string to uint8 to make arrays of static size and use them as a dictionnarywaf.HandleMetrics
replace a lot of makes with keys beingRASPRuleType
with an arrayxsync.MapOf
config.Origin
type and replace it by the more general purposetelemetry.Origin
(That I am thinking of promoting to the packageinternal/globalconfig
🤔 )Motivation
Reviewer's Checklist
v2-dev
branch and reviewed by @DataDog/apm-go.Unsure? Have a question? Request a review!