Skip to content
This repository was archived by the owner on Apr 3, 2026. It is now read-only.

fix: make appsec.DefaultRuleset reutrn the ruleset as-is#46

Merged
RomainMuller merged 2 commits intomainfrom
romain.marcadier/APPSEC-57708/inefficiencies
May 19, 2025
Merged

fix: make appsec.DefaultRuleset reutrn the ruleset as-is#46
RomainMuller merged 2 commits intomainfrom
romain.marcadier/APPSEC-57708/inefficiencies

Conversation

@RomainMuller
Copy link
Copy Markdown
Contributor

The DefaultRuleset function used to re-marshal a JSON document that was just parsed; as an artifact from times where the processors were merged into the ruleset separately. This has not been needed since a long time, as the default ruleset now includes the relevant processors already.

This removes inefficiencies as we no longer have to parse, then format the data. The embedded object is also carried directly as a []byte slice instead of a string, to remove the need for a string copy to happen all the time.

@RomainMuller RomainMuller requested a review from a team as a code owner May 19, 2025 09:14
Comment thread appsec/embed.go

// StaticRecommendedRules holds the recommended AppSec security rules (v1.14.2)
// Source: https://github.com/DataDog/appsec-event-rules/blob/1.14.2/build/recommended.json
StaticRecommendedRules = unsafe.String(&staticRecommendedRules[0], len(staticRecommendedRules))
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to retain the exported symbol (otherwise it's a breaking change) while avoiding to cause a full copy of the backing data to be done (because it's unnecessary).

That symbol would be dropped in a future version.

@RomainMuller RomainMuller merged commit 77e25f6 into main May 19, 2025
40 of 41 checks passed
@RomainMuller RomainMuller deleted the romain.marcadier/APPSEC-57708/inefficiencies branch May 19, 2025 13:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants