Skip to content

Commit

Permalink
fix: Tolerate additional fields in App Protect yaml files (#494)
Browse files Browse the repository at this point in the history
The format of "/opt/app_protect/var/update_files/signatures/signature_update.yaml"
from the latest Attack Signature update (2023.10.04) contained
additional items. Changed the parsing of the yaml file to not be
"strict" to maintain compatibility across versions.

Co-authored-by: edarzins <[email protected]>
  • Loading branch information
edarzins and FRC2240 authored Oct 6, 2023
1 parent 6d098af commit 61f22ec
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/extensions/nginx-app-protect/nap/attack_signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getAttackSignaturesVersion(versionFile string) (string, error) {

// Read bytes into object
attackSigVersionDateTime := napRevisionDateTime{}
err = yaml.UnmarshalStrict([]byte(versionBytes), &attackSigVersionDateTime)
err = yaml.Unmarshal([]byte(versionBytes), &attackSigVersionDateTime)
if err != nil {
return "", err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const (
testAttackSigVersionFileContents = `---
checksum: t+N7AHGIKPhdDwb8zMZh2w
filename: signatures.bin.tgz
revisionDatetime: 2022-02-24T20:32:01Z`
revisionDatetime: 2022-02-24T20:32:01Z
distro: focal
osType: debian`
)

func TestGetAttackSignaturesVersion(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/nginx-app-protect/nap/threat_campaigns.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func getThreatCampaignsVersion(versionFile string) (string, error) {

// Read bytes into object
threatCampVersionDateTime := napRevisionDateTime{}
err = yaml.UnmarshalStrict([]byte(versionBytes), &threatCampVersionDateTime)
err = yaml.Unmarshal([]byte(versionBytes), &threatCampVersionDateTime)
if err != nil {
return "", err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const (
testThreatCampaignsVersionFileContents = `---
checksum: ALCdgk8CQgQQLRJ1ydZA4g
filename: threat_campaigns.bin.tgz
revisionDatetime: 2022-03-01T20:32:01Z`
revisionDatetime: 2022-03-01T20:32:01Z
distro: focal
osType: debian`
)

func TestGetThreatCampaignsVersion(t *testing.T) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 61f22ec

Please sign in to comment.