From 4dd65dade08178b1739f77d43cb8f569b9835f1f Mon Sep 17 00:00:00 2001 From: Nick Chen Date: Wed, 9 Nov 2022 14:18:55 -0800 Subject: [PATCH 1/2] fix: remove explicit nap version mapping --- .../nginx-app-protect/nap/errors.go | 2 +- src/extensions/nginx-app-protect/nap/nap.go | 25 +- .../nginx-app-protect/nap/nap_release.go | 59 +-- .../nginx-app-protect/nap/nap_release_test.go | 42 +- .../nginx-app-protect/nap/nap_test.go | 4 +- .../nginx-app-protect/nap/releases.go | 469 +----------------- src/plugins/nginx_app_protect_test.go | 9 +- 7 files changed, 33 insertions(+), 577 deletions(-) diff --git a/src/extensions/nginx-app-protect/nap/errors.go b/src/extensions/nginx-app-protect/nap/errors.go index 15a588aa6..1beca4adf 100644 --- a/src/extensions/nginx-app-protect/nap/errors.go +++ b/src/extensions/nginx-app-protect/nap/errors.go @@ -1,7 +1,7 @@ package nap const ( - FILE_NOT_FOUND = "The following file could not be found - %s" + FILE_NOT_FOUND = "the following file could not be found - %s" UNABLE_TO_MATCH_NAP_BUILD_VERSION = "Couldn't match the NAP build version (%s) to a supported NAP release..." UNABLE_TO_FIND_RELEASE_VERSION_INFO = "Unable to find NAP release info for supplied NAP release version - %s" UNSUPPORTED_NAP_RELEASE_VERSION = "The supplied release version (%s) is not within the supported release versions - %v" diff --git a/src/extensions/nginx-app-protect/nap/nap.go b/src/extensions/nginx-app-protect/nap/nap.go index 68cc18d3d..0ec29eb5b 100644 --- a/src/extensions/nginx-app-protect/nap/nap.go +++ b/src/extensions/nginx-app-protect/nap/nap.go @@ -7,8 +7,9 @@ import ( "strings" "time" - "github.com/nginx/agent/v2/src/core" log "github.com/sirupsen/logrus" + + "github.com/nginx/agent/v2/src/core" ) const ( @@ -40,14 +41,14 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) } // Get status of NAP on the system - napStatus, err := napStatus(requiredNAPFiles) + status, err := napStatus(requiredNAPFiles) if err != nil { return nil, err } // Get the release version of NAP on the system if NAP is installed var napRelease *NAPRelease - if napStatus != MISSING { + if status != MISSING { napRelease, err = installedNAPRelease(NAP_VERSION_FILE) if err != nil { return nil, err @@ -55,7 +56,7 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) } // Update the NAP object with the values from NAP on the system - nap.Status = napStatus.String() + nap.Status = status.String() if napRelease != nil { nap.Release = *napRelease } @@ -65,7 +66,7 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) // Monitor starts a goroutine responsible for monitoring the system for any NAP related // changes and communicates those changes with a report message sent via the channel this -// function returns. Additionally if any changes are detected the NAP object that called +// function returns. Additionally, if any changes are detected the NAP object that called // this monitoring function will have its attributes updated to the new changes. Here are // examples of NAP changes that would be detected and communicated: // - NAP installed/version changed @@ -106,7 +107,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva // Check if there has been any change in the NAP report if nap.napReportIsEqual(newNAPReport) { - log.Infof("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) + log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) break } @@ -183,7 +184,7 @@ func (nap *NginxAppProtect) syncSymLink(previousVersion, newVersion string) erro } // removeNAPSymlinks walks the NAP symlink directory and removes any existing NAP -// symlinks found in the directory except for ones that match the ignore pattern. +// symlinks found in the directory except for ones that match to ignore pattern. func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) error { // Check if the necessary directory exists _, err := os.Stat(nap.symLinkDir) @@ -235,7 +236,7 @@ func (nap *NginxAppProtect) napReportIsEqual(incomingNAPReport NAPReport) bool { // napInstalled determines if NAP is installed on the system. If NAP is NOT installed on the // system then the bool will be false and the error will be nil, if the error is not nil then -// it's possible NAP might be installed but an error verifying it's installation has occurred. +// it's possible NAP might be installed but an error verifying its installation has occurred. func napInstalled(requiredFiles []string) (bool, error) { log.Debugf("Checking for the required NAP files - %v\n", requiredFiles) return core.FilesExists(requiredFiles) @@ -267,16 +268,16 @@ func napRunning() (bool, error) { func napStatus(requiredFiles []string) (Status, error) { // Check if NAP is installed - napInstalled, err := napInstalled(requiredFiles) - if !napInstalled && err == nil { + installed, err := napInstalled(requiredFiles) + if !installed && err == nil { return MISSING, nil } else if err != nil { return UNDEFINED, err } // It's installed, but is running? - napRunning, err := napRunning() - if !napRunning && err == nil { + running, err := napRunning() + if !running && err == nil { return INSTALLED, nil } else if err != nil { return UNDEFINED, err diff --git a/src/extensions/nginx-app-protect/nap/nap_release.go b/src/extensions/nginx-app-protect/nap/nap_release.go index bbae030f2..d48140cad 100644 --- a/src/extensions/nginx-app-protect/nap/nap_release.go +++ b/src/extensions/nginx-app-protect/nap/nap_release.go @@ -1,74 +1,23 @@ package nap import ( - "errors" "fmt" - "io/ioutil" + "os" "strings" "github.com/nginx/agent/v2/src/core" ) -// NewNAPReleaseMap is responsible for creating a NAPReleaseMap object that is contains -// info about each support NAP release. -func NewNAPReleaseMap() *NAPReleaseMap { - return &NAPReleaseMap{ - ReleaseMap: map[string]NAPRelease{ - "3.12.2": NAPRelease3_12_2(), - "3.12": NAPRelease3_12(), - "3.11": NAPRelease3_11(), - "3.10": NAPRelease3_10(), - "3.9.1": NAPRelease3_9_1(), - "3.9": NAPRelease3_9(), - "3.8": NAPRelease3_8(), - "3.7": NAPRelease3_7(), - "3.6": NAPRelease3_6(), - "3.5": NAPRelease3_5(), - "3.4": NAPRelease3_4(), - "3.3": NAPRelease3_3(), - "3.2": NAPRelease3_2(), - "3.1": NAPRelease3_1(), - "3.0": NAPRelease3_0(), - }, - } -} - -// NAPReleaseInfo get the NAP release information for a specified NAP release version. -func NAPReleaseInfo(napReleaseVersion string) (*NAPRelease, error) { - napRelease, exists := NewNAPReleaseMap().ReleaseMap[napReleaseVersion] - if !exists { - // Couldn't find details for supplied version - msg := fmt.Sprintf(UNABLE_TO_FIND_RELEASE_VERSION_INFO, napReleaseVersion) - logger.Error(msg) - return nil, errors.New(msg) - } - - return &napRelease, nil -} - // installedNAPRelease gets the NAP release version based off the Nginx App Protect installed // on the system. func installedNAPRelease(versionFile string) (*NAPRelease, error) { - // Get build version of NAP so we can determine the release details + // Get build version of NAP, so we can determine the release details napBuildVersion, err := installedNAPBuildVersion(versionFile) if err != nil { return nil, err } - // Try to match NAP system build version to a build version in the NAP version mapping obj - for releaseVersion, napRelease := range NewNAPReleaseMap().ReleaseMap { - if napBuildVersion == napRelease.VersioningDetails.NAPBuild { - logger.Debugf("Matched the NAP build version (%s) to the NAP release version (%s)\n", napBuildVersion, releaseVersion) - return &napRelease, nil - } - } - - // No match found but we'll return a release with a build version - logger.Errorf(UNABLE_TO_MATCH_NAP_BUILD_VERSION, napBuildVersion) - logger.Warnf("Returning NAP release with only build number - %s", napBuildVersion) - - unmappedRelease := NAPReleaseUnmappedBuild(napBuildVersion) - + unmappedRelease := ReleaseUnmappedBuild(napBuildVersion) return &unmappedRelease, nil } @@ -83,7 +32,7 @@ func installedNAPBuildVersion(versionFile string) (string, error) { return "", err } - versionBytes, err := ioutil.ReadFile(versionFile) + versionBytes, err := os.ReadFile(versionFile) if err != nil { return "", err } diff --git a/src/extensions/nginx-app-protect/nap/nap_release_test.go b/src/extensions/nginx-app-protect/nap/nap_release_test.go index 477da53b3..e99985bbc 100644 --- a/src/extensions/nginx-app-protect/nap/nap_release_test.go +++ b/src/extensions/nginx-app-protect/nap/nap_release_test.go @@ -15,43 +15,9 @@ const ( ) var ( - napRelease3_9 = NAPRelease3_9() - testUnmappedBuildRelease = NAPReleaseUnmappedBuild(testUnsupportedVersion) + testUnmappedBuildRelease = ReleaseUnmappedBuild(testUnsupportedVersion) ) -func TestNAPReleaseInfo(t *testing.T) { - testCases := []struct { - testName string - napReleaseVersion string - expReleaseVersion *NAPRelease - expError error - }{ - { - testName: "ValidNAPRelease", - napReleaseVersion: "3.9", - expReleaseVersion: &napRelease3_9, - expError: nil, - }, - { - testName: "InvalidNAPRelease", - napReleaseVersion: "invalid-release", - expReleaseVersion: nil, - expError: fmt.Errorf(UNABLE_TO_FIND_RELEASE_VERSION_INFO, "invalid-release"), - }, - } - - for _, tc := range testCases { - t.Run(tc.testName, func(t *testing.T) { - // Get release version info - releaseVersion, err := NAPReleaseInfo(tc.napReleaseVersion) - - // Validate returned release info - assert.Equal(t, err, tc.expError) - assert.Equal(t, releaseVersion, tc.expReleaseVersion) - }) - } -} - func TestInstalledNAPBuildVersion(t *testing.T) { testCases := []struct { testName string @@ -100,6 +66,10 @@ func TestInstalledNAPBuildVersion(t *testing.T) { } } +func buildFromPTR(v string) *NAPRelease { + version := ReleaseUnmappedBuild(v) + return &version +} func TestInstalledNAPRelease(t *testing.T) { testCases := []struct { testName string @@ -119,7 +89,7 @@ func TestInstalledNAPRelease(t *testing.T) { testName: "SuccessfullyGetNAPReleaseVersion", versionFile: testNAPVersionFile, version: testNAPVersion, - expReleaseVersion: &napRelease3_9, + expReleaseVersion: buildFromPTR(testNAPVersion), expError: nil, }, { diff --git a/src/extensions/nginx-app-protect/nap/nap_test.go b/src/extensions/nginx-app-protect/nap/nap_test.go index 50fb71d77..347e2d73f 100644 --- a/src/extensions/nginx-app-protect/nap/nap_test.go +++ b/src/extensions/nginx-app-protect/nap/nap_test.go @@ -58,13 +58,13 @@ func TestGenerateNAPReport(t *testing.T) { testName: "NAPInstalled", nap: NginxAppProtect{ Status: INSTALLED.String(), - Release: napRelease3_9, + Release: testUnmappedBuildRelease, AttackSignaturesVersion: "2022.02.24", ThreatCampaignsVersion: "2022.03.01", }, expNAPReport: NAPReport{ Status: INSTALLED.String(), - NAPVersion: napRelease3_9.VersioningDetails.NAPRelease, + NAPVersion: testUnmappedBuildRelease.VersioningDetails.NAPRelease, AttackSignaturesVersion: "2022.02.24", ThreatCampaignsVersion: "2022.03.01", }, diff --git a/src/extensions/nginx-app-protect/nap/releases.go b/src/extensions/nginx-app-protect/nap/releases.go index 6b5dfde84..7f67c92ed 100644 --- a/src/extensions/nginx-app-protect/nap/releases.go +++ b/src/extensions/nginx-app-protect/nap/releases.go @@ -1,471 +1,6 @@ package nap -// NAPRelease3_12_2 returns information regarding packages and versioning for NAP release -// version 3.12.2. -func NAPRelease3_12_2() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-27+3.1088.2-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-27+3.1088.2-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_27+3.1088.2~buster_amd64.deb", - Redhat7: "app-protect-27+3.1088.2-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-27+3.1088.2-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_27+3.1088.2~bionic_amd64.deb", - Ubuntu2004: "app-protect_27+3.1088.2~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.1088.2", - NAPCompiler: "10.139.2", - NAPEngine: "10.139.2", - NAPPlugin: "3.1088.2", - NAPPlusModule: "27+3.1088.2", - NAPRelease: "3.12.2", - NginxPlus: "27", - }, - } -} - -// NAPRelease3_12 returns information regarding packages and versioning for NAP release -// version 3.12. -func NAPRelease3_12() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-27+3.1088.1-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-27+3.1088.1-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_27+3.1088.1~buster_amd64.deb", - Redhat7: "app-protect-27+3.1088.1-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-27+3.1088.1-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_27+3.1088.1~bionic_amd64.deb", - Ubuntu2004: "app-protect_27+3.1088.1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.1088.1", - NAPCompiler: "10.139.1", - NAPEngine: "10.139.1", - NAPPlugin: "3.1088.1", - NAPPlusModule: "27+3.1088.1", - NAPRelease: "3.12", - NginxPlus: "27", - }, - } -} - -// NAPRelease3_11 returns information regarding packages and versioning for NAP release -// version 3.11. -func NAPRelease3_11() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-27+3.954.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-27+3.954.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_27+3.954.0-1~buster_amd64.deb", - Redhat7: "app-protect-27+3.954.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-27+3.954.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_27+3.954.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_27+3.954.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.954.0", - NAPCompiler: "10.87.0", - NAPEngine: "10.87.0", - NAPPlugin: "3.954.0", - NAPPlusModule: "27+3.954.0", - NAPRelease: "3.11", - NginxPlus: "27", - }, - } -} - -// NAPRelease3_10 returns information regarding packages and versioning for NAP release -// version 3.10. -func NAPRelease3_10() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-26+3.890.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-26+3.890.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_26+3.890.0-1~buster_amd64.deb", - Redhat7: "app-protect-26+3.890.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-26+3.890.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_26+3.890.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_26+3.890.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.890.0", - NAPCompiler: "10.58.0", - NAPEngine: "10.58.0", - NAPPlugin: "3.890.0", - NAPPlusModule: "26+3.890.0", - NAPRelease: "3.10", - NginxPlus: "26", - }, - } -} - -// NAPRelease3_9_1 returns information regarding packages and versioning for NAP release -// version 3.9.1. -func NAPRelease3_9_1() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-26+3.796.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-26+3.796.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_26+3.796.0-1~buster_amd64.deb", - Redhat7: "app-protect-26+3.796.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-26+3.796.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_26+3.796.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_26+3.796.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.796.0", - NAPCompiler: "10.29.1", - NAPEngine: "10.29.1", - NAPPlugin: "3.796.0", - NAPPlusModule: "26+3.796.0", - NAPRelease: "3.9.1", - NginxPlus: "26", - }, - } -} - -// NAPRelease3_9 returns information regarding packages and versioning for NAP release -// version 3.9. -func NAPRelease3_9() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-26+3.780.1-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-26+3.780.1-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_26+3.780.1-1~buster_amd64.deb", - Redhat7: "app-protect-26+3.780.1-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-26+3.780.1-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_26+3.780.1-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_26+3.780.1-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.780.1", - NAPCompiler: "10.16.5", - NAPEngine: "10.16.5", - NAPPlugin: "3.780.1", - NAPPlusModule: "26+3.780.1", - NAPRelease: "3.9", - NginxPlus: "26", - }, - } -} - -// NAPRelease3_8 returns information regarding packages and versioning for NAP release -// version 3.8. -func NAPRelease3_8() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-25+3.760.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-25+3.760.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_25+3.760.0-1~buster_amd64.deb", - Redhat7: "app-protect-25+3.760.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-25+3.760.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_25+3.760.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_25+3.760.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.760.0", - NAPCompiler: "9.15.0", - NAPEngine: "9.15.0", - NAPPlugin: "3.760.0", - NAPPlusModule: "25+3.760.0", - NAPRelease: "3.8", - NginxPlus: "25", - }, - } -} - -// NAPRelease3_7 returns information regarding packages and versioning for NAP release -// version 3.7. -func NAPRelease3_7() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-25+3.733.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-25+3.733.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_25+3.733.0-1~buster_amd64.deb", - Redhat7: "app-protect-25+3.733.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_25+3.733.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_25+3.733.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.733.0", - NAPCompiler: "9.15.0", - NAPEngine: "9.15.0", - NAPPlugin: "3.733.0", - NAPPlusModule: "25+3.733.0", - NAPRelease: "3.7", - NginxPlus: "25", - }, - } -} - -// NAPRelease3_6 returns information regarding packages and versioning for NAP release -// version 3.6. -func NAPRelease3_6() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-25+3.671.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-25+3.671.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_25+3.671.0-1~buster_amd64.deb", - Redhat7: "app-protect-25+3.671.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_25+3.671.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_25+3.671.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.671.0", - NAPCompiler: "8.12.1", - NAPEngine: "8.12.1", - NAPPlugin: "3.671.0", - NAPPlusModule: "25+3.671.0", - NAPRelease: "3.6", - NginxPlus: "25", - }, - } -} - -// NAPRelease3_5 returns information regarding packages and versioning for NAP release -// version 3.5. -func NAPRelease3_5() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.639.0-r1.apk", - AmazonLinux2: "app-protect-24+3.639.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-24+3.639.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.639.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.639.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.639.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.639.0-1~focal_amd64.de", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.639.0", - NAPCompiler: "8.7.4", - NAPEngine: "8.7.4", - NAPPlugin: "3.639.0", - NAPPlusModule: "24+3.639.0", - NAPRelease: "3.5", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_4 returns information regarding packages and versioning for NAP release -// version 3.4. -func NAPRelease3_4() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.612.0-r1.apk", - AmazonLinux2: "app-protect-24+3.612.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-24+3.612.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.612.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.612.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.612.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.612.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.612.0", - NAPCompiler: "7.19.6", - NAPEngine: "7.19.6", - NAPPlugin: "3.612.0", - NAPPlusModule: "24+3.612.0", - NAPRelease: "3.4", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_3 returns information regarding packages and versioning for NAP release -// version 3.3. -func NAPRelease3_3() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.583.0-r1.apk", - AmazonLinux2: "app-protect-24+3.583.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-24+3.583.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.583.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.583.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.583.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.583.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.583.0", - NAPCompiler: "7.7.7", - NAPEngine: "7.7.7", - NAPPlugin: "3.583.0", - NAPPlusModule: "24+3.583.0", - NAPRelease: "3.3", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_2 returns information regarding packages and versioning for NAP release -// version 3.2. -func NAPRelease3_2() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.512.0-r1.apk", - AmazonLinux2: "", - Centos7: "app-protect-24+3.512.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.512.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.512.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.512.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.512.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.512.0", - NAPCompiler: "6.64.2", - NAPEngine: "6.64.2", - NAPPlugin: "3.512.0", - NAPPlusModule: "24+3.512.0", - NAPRelease: "3.2", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_1 returns information regarding packages and versioning for NAP release -// version 3.1. -func NAPRelease3_1() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-23.3.462.0-r1.apk", - AmazonLinux2: "", - Centos7: "app-protect-23+3.462.0-1.el7.ngx.x86_64.rpm", - Debian9: "app-protect_23+3.462.0-1~stretch_amd64.deb", - Debian10: "app-protect_23+3.462.0-1~buster_amd64.deb", - Redhat7: "app-protect-23+3.462.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_23+3.462.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_23+3.462.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.462.0", - NAPCompiler: "6.53.1", - NAPEngine: "6.53.1", - NAPPlugin: "3.462.0", - NAPPlusModule: "23+3.462.0", - NAPRelease: "3.1", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_0 returns information regarding packages and versioning for NAP release -// version 3.0. -func NAPRelease3_0() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-23.3.332.0-r1.apk", - AmazonLinux2: "", - Centos7: "app-protect-23+3.332.0-1.el7.ngx.x86_64.rpm", - Debian9: "app-protect_23+3.332.0-1~stretch_amd64.deb", - Debian10: "app-protect_23+3.332.0-1~buster_amd64.deb", - Redhat7: "app-protect-23+3.332.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_23+3.332.0-1~bionic_amd64.deb", - Ubuntu2004: "", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.332.0", - NAPCompiler: "6.3.6", - NAPEngine: "6.3.6", - NAPPlugin: "3.332.0", - NAPPlusModule: "23+3.332.0", - NAPRelease: "3.0", - NginxPlus: "23", - }, - } -} - -func NAPReleaseUnmappedBuild(buildVersion string) NAPRelease { +func ReleaseUnmappedBuild(buildVersion string) NAPRelease { return NAPRelease{ NAPPackages: NAPReleasePackages{}, NAPCompilerPackages: NAPReleasePackages{}, @@ -474,7 +9,7 @@ func NAPReleaseUnmappedBuild(buildVersion string) NAPRelease { NAPPlusModulePackages: NAPReleasePackages{}, VersioningDetails: NAPVersioningDetails{ NAPBuild: buildVersion, - NAPRelease: "build-" + buildVersion, + NAPRelease: buildVersion, }, } } diff --git a/src/plugins/nginx_app_protect_test.go b/src/plugins/nginx_app_protect_test.go index dbae6054b..df63cbfdd 100644 --- a/src/plugins/nginx_app_protect_test.go +++ b/src/plugins/nginx_app_protect_test.go @@ -18,12 +18,13 @@ const ( testSystemID = "12345678" testSigDate1 = "2022.02.14" testCampaignDate1 = "2022.02.07" + testWAFVersion = "3.780.1" ) var ( testNAPDetailsActive = &proto.DataplaneSoftwareDetails_AppProtectWafDetails{ AppProtectWafDetails: &proto.AppProtectWAFDetails{ - WafVersion: nap.NAPRelease3_9().VersioningDetails.NAPRelease, + WafVersion: testWAFVersion, AttackSignaturesVersion: testSigDate1, ThreatCampaignsVersion: testCampaignDate1, Health: &proto.AppProtectWAFHealth{ @@ -44,7 +45,7 @@ var ( testNAPDetailsDegraded = &proto.DataplaneSoftwareDetails_AppProtectWafDetails{ AppProtectWafDetails: &proto.AppProtectWAFDetails{ - WafVersion: nap.NAPRelease3_9().VersioningDetails.NAPRelease, + WafVersion: testWAFVersion, AttackSignaturesVersion: testSigDate1, ThreatCampaignsVersion: testCampaignDate1, Health: &proto.AppProtectWAFHealth{ @@ -81,7 +82,7 @@ func TestNginxAppProtect(t *testing.T) { Status: nap.RUNNING.String(), AttackSignaturesVersion: testSigDate1, ThreatCampaignsVersion: testCampaignDate1, - Release: nap.NAPRelease3_9(), + Release: nap.ReleaseUnmappedBuild("3.780.1"), } currentNAPPluginDetails = napPlugin.generateNAPDetailsProtoCommand() assert.Equal(t, testNAPDetailsActive, currentNAPPluginDetails) @@ -91,7 +92,7 @@ func TestNginxAppProtect(t *testing.T) { Status: nap.INSTALLED.String(), AttackSignaturesVersion: testSigDate1, ThreatCampaignsVersion: testCampaignDate1, - Release: nap.NAPRelease3_9(), + Release: nap.ReleaseUnmappedBuild("3.780.1"), } currentNAPPluginDetails = napPlugin.generateNAPDetailsProtoCommand() assert.Equal(t, testNAPDetailsDegraded, currentNAPPluginDetails) From 6a75c741748df8709b1448842b2c75a58c6df7d8 Mon Sep 17 00:00:00 2001 From: Nick Chen Date: Wed, 9 Nov 2022 19:37:40 -0800 Subject: [PATCH 2/2] fix: add make deps --- sdk/proto/events/event.pb.go | 1 + .../agent/sdk/v2/proto/events/event.pb.go | 1 + .../nginx-app-protect/nap/errors.go | 2 +- .../extensions/nginx-app-protect/nap/nap.go | 25 +- .../nginx-app-protect/nap/nap_release.go | 59 +-- .../nginx-app-protect/nap/releases.go | 469 +----------------- .../agent/sdk/v2/proto/events/event.pb.go | 1 + 7 files changed, 23 insertions(+), 535 deletions(-) diff --git a/sdk/proto/events/event.pb.go b/sdk/proto/events/event.pb.go index cab3f517d..dfb5f1526 100644 --- a/sdk/proto/events/event.pb.go +++ b/sdk/proto/events/event.pb.go @@ -123,6 +123,7 @@ func (m *Metadata) GetCategory() string { type Event struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3" json:"metadata"` // Types that are valid to be assigned to Data: + // // *Event_ActivityEvent // *Event_SecurityViolationEvent Data isEvent_Data `protobuf_oneof:"data"` diff --git a/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go b/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go index cab3f517d..dfb5f1526 100644 --- a/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go +++ b/test/performance/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go @@ -123,6 +123,7 @@ func (m *Metadata) GetCategory() string { type Event struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3" json:"metadata"` // Types that are valid to be assigned to Data: + // // *Event_ActivityEvent // *Event_SecurityViolationEvent Data isEvent_Data `protobuf_oneof:"data"` diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/errors.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/errors.go index 15a588aa6..1beca4adf 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/errors.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/errors.go @@ -1,7 +1,7 @@ package nap const ( - FILE_NOT_FOUND = "The following file could not be found - %s" + FILE_NOT_FOUND = "the following file could not be found - %s" UNABLE_TO_MATCH_NAP_BUILD_VERSION = "Couldn't match the NAP build version (%s) to a supported NAP release..." UNABLE_TO_FIND_RELEASE_VERSION_INFO = "Unable to find NAP release info for supplied NAP release version - %s" UNSUPPORTED_NAP_RELEASE_VERSION = "The supplied release version (%s) is not within the supported release versions - %v" diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go index 68cc18d3d..0ec29eb5b 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap.go @@ -7,8 +7,9 @@ import ( "strings" "time" - "github.com/nginx/agent/v2/src/core" log "github.com/sirupsen/logrus" + + "github.com/nginx/agent/v2/src/core" ) const ( @@ -40,14 +41,14 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) } // Get status of NAP on the system - napStatus, err := napStatus(requiredNAPFiles) + status, err := napStatus(requiredNAPFiles) if err != nil { return nil, err } // Get the release version of NAP on the system if NAP is installed var napRelease *NAPRelease - if napStatus != MISSING { + if status != MISSING { napRelease, err = installedNAPRelease(NAP_VERSION_FILE) if err != nil { return nil, err @@ -55,7 +56,7 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) } // Update the NAP object with the values from NAP on the system - nap.Status = napStatus.String() + nap.Status = status.String() if napRelease != nil { nap.Release = *napRelease } @@ -65,7 +66,7 @@ func NewNginxAppProtect(optDirPath, symLinkDir string) (*NginxAppProtect, error) // Monitor starts a goroutine responsible for monitoring the system for any NAP related // changes and communicates those changes with a report message sent via the channel this -// function returns. Additionally if any changes are detected the NAP object that called +// function returns. Additionally, if any changes are detected the NAP object that called // this monitoring function will have its attributes updated to the new changes. Here are // examples of NAP changes that would be detected and communicated: // - NAP installed/version changed @@ -106,7 +107,7 @@ func (nap *NginxAppProtect) monitor(msgChannel chan NAPReportBundle, pollInterva // Check if there has been any change in the NAP report if nap.napReportIsEqual(newNAPReport) { - log.Infof("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) + log.Debugf("No change in NAP detected... Checking NAP again in %v seconds", pollInterval.Seconds()) break } @@ -183,7 +184,7 @@ func (nap *NginxAppProtect) syncSymLink(previousVersion, newVersion string) erro } // removeNAPSymlinks walks the NAP symlink directory and removes any existing NAP -// symlinks found in the directory except for ones that match the ignore pattern. +// symlinks found in the directory except for ones that match to ignore pattern. func (nap *NginxAppProtect) removeNAPSymlinks(symlinkPatternToIgnore string) error { // Check if the necessary directory exists _, err := os.Stat(nap.symLinkDir) @@ -235,7 +236,7 @@ func (nap *NginxAppProtect) napReportIsEqual(incomingNAPReport NAPReport) bool { // napInstalled determines if NAP is installed on the system. If NAP is NOT installed on the // system then the bool will be false and the error will be nil, if the error is not nil then -// it's possible NAP might be installed but an error verifying it's installation has occurred. +// it's possible NAP might be installed but an error verifying its installation has occurred. func napInstalled(requiredFiles []string) (bool, error) { log.Debugf("Checking for the required NAP files - %v\n", requiredFiles) return core.FilesExists(requiredFiles) @@ -267,16 +268,16 @@ func napRunning() (bool, error) { func napStatus(requiredFiles []string) (Status, error) { // Check if NAP is installed - napInstalled, err := napInstalled(requiredFiles) - if !napInstalled && err == nil { + installed, err := napInstalled(requiredFiles) + if !installed && err == nil { return MISSING, nil } else if err != nil { return UNDEFINED, err } // It's installed, but is running? - napRunning, err := napRunning() - if !napRunning && err == nil { + running, err := napRunning() + if !running && err == nil { return INSTALLED, nil } else if err != nil { return UNDEFINED, err diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap_release.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap_release.go index bbae030f2..d48140cad 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap_release.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/nap_release.go @@ -1,74 +1,23 @@ package nap import ( - "errors" "fmt" - "io/ioutil" + "os" "strings" "github.com/nginx/agent/v2/src/core" ) -// NewNAPReleaseMap is responsible for creating a NAPReleaseMap object that is contains -// info about each support NAP release. -func NewNAPReleaseMap() *NAPReleaseMap { - return &NAPReleaseMap{ - ReleaseMap: map[string]NAPRelease{ - "3.12.2": NAPRelease3_12_2(), - "3.12": NAPRelease3_12(), - "3.11": NAPRelease3_11(), - "3.10": NAPRelease3_10(), - "3.9.1": NAPRelease3_9_1(), - "3.9": NAPRelease3_9(), - "3.8": NAPRelease3_8(), - "3.7": NAPRelease3_7(), - "3.6": NAPRelease3_6(), - "3.5": NAPRelease3_5(), - "3.4": NAPRelease3_4(), - "3.3": NAPRelease3_3(), - "3.2": NAPRelease3_2(), - "3.1": NAPRelease3_1(), - "3.0": NAPRelease3_0(), - }, - } -} - -// NAPReleaseInfo get the NAP release information for a specified NAP release version. -func NAPReleaseInfo(napReleaseVersion string) (*NAPRelease, error) { - napRelease, exists := NewNAPReleaseMap().ReleaseMap[napReleaseVersion] - if !exists { - // Couldn't find details for supplied version - msg := fmt.Sprintf(UNABLE_TO_FIND_RELEASE_VERSION_INFO, napReleaseVersion) - logger.Error(msg) - return nil, errors.New(msg) - } - - return &napRelease, nil -} - // installedNAPRelease gets the NAP release version based off the Nginx App Protect installed // on the system. func installedNAPRelease(versionFile string) (*NAPRelease, error) { - // Get build version of NAP so we can determine the release details + // Get build version of NAP, so we can determine the release details napBuildVersion, err := installedNAPBuildVersion(versionFile) if err != nil { return nil, err } - // Try to match NAP system build version to a build version in the NAP version mapping obj - for releaseVersion, napRelease := range NewNAPReleaseMap().ReleaseMap { - if napBuildVersion == napRelease.VersioningDetails.NAPBuild { - logger.Debugf("Matched the NAP build version (%s) to the NAP release version (%s)\n", napBuildVersion, releaseVersion) - return &napRelease, nil - } - } - - // No match found but we'll return a release with a build version - logger.Errorf(UNABLE_TO_MATCH_NAP_BUILD_VERSION, napBuildVersion) - logger.Warnf("Returning NAP release with only build number - %s", napBuildVersion) - - unmappedRelease := NAPReleaseUnmappedBuild(napBuildVersion) - + unmappedRelease := ReleaseUnmappedBuild(napBuildVersion) return &unmappedRelease, nil } @@ -83,7 +32,7 @@ func installedNAPBuildVersion(versionFile string) (string, error) { return "", err } - versionBytes, err := ioutil.ReadFile(versionFile) + versionBytes, err := os.ReadFile(versionFile) if err != nil { return "", err } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/releases.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/releases.go index 6b5dfde84..7f67c92ed 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/releases.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/nap/releases.go @@ -1,471 +1,6 @@ package nap -// NAPRelease3_12_2 returns information regarding packages and versioning for NAP release -// version 3.12.2. -func NAPRelease3_12_2() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-27+3.1088.2-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-27+3.1088.2-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_27+3.1088.2~buster_amd64.deb", - Redhat7: "app-protect-27+3.1088.2-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-27+3.1088.2-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_27+3.1088.2~bionic_amd64.deb", - Ubuntu2004: "app-protect_27+3.1088.2~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.1088.2", - NAPCompiler: "10.139.2", - NAPEngine: "10.139.2", - NAPPlugin: "3.1088.2", - NAPPlusModule: "27+3.1088.2", - NAPRelease: "3.12.2", - NginxPlus: "27", - }, - } -} - -// NAPRelease3_12 returns information regarding packages and versioning for NAP release -// version 3.12. -func NAPRelease3_12() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-27+3.1088.1-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-27+3.1088.1-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_27+3.1088.1~buster_amd64.deb", - Redhat7: "app-protect-27+3.1088.1-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-27+3.1088.1-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_27+3.1088.1~bionic_amd64.deb", - Ubuntu2004: "app-protect_27+3.1088.1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.1088.1", - NAPCompiler: "10.139.1", - NAPEngine: "10.139.1", - NAPPlugin: "3.1088.1", - NAPPlusModule: "27+3.1088.1", - NAPRelease: "3.12", - NginxPlus: "27", - }, - } -} - -// NAPRelease3_11 returns information regarding packages and versioning for NAP release -// version 3.11. -func NAPRelease3_11() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-27+3.954.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-27+3.954.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_27+3.954.0-1~buster_amd64.deb", - Redhat7: "app-protect-27+3.954.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-27+3.954.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_27+3.954.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_27+3.954.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.954.0", - NAPCompiler: "10.87.0", - NAPEngine: "10.87.0", - NAPPlugin: "3.954.0", - NAPPlusModule: "27+3.954.0", - NAPRelease: "3.11", - NginxPlus: "27", - }, - } -} - -// NAPRelease3_10 returns information regarding packages and versioning for NAP release -// version 3.10. -func NAPRelease3_10() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-26+3.890.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-26+3.890.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_26+3.890.0-1~buster_amd64.deb", - Redhat7: "app-protect-26+3.890.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-26+3.890.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_26+3.890.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_26+3.890.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.890.0", - NAPCompiler: "10.58.0", - NAPEngine: "10.58.0", - NAPPlugin: "3.890.0", - NAPPlusModule: "26+3.890.0", - NAPRelease: "3.10", - NginxPlus: "26", - }, - } -} - -// NAPRelease3_9_1 returns information regarding packages and versioning for NAP release -// version 3.9.1. -func NAPRelease3_9_1() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-26+3.796.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-26+3.796.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_26+3.796.0-1~buster_amd64.deb", - Redhat7: "app-protect-26+3.796.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-26+3.796.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_26+3.796.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_26+3.796.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.796.0", - NAPCompiler: "10.29.1", - NAPEngine: "10.29.1", - NAPPlugin: "3.796.0", - NAPPlusModule: "26+3.796.0", - NAPRelease: "3.9.1", - NginxPlus: "26", - }, - } -} - -// NAPRelease3_9 returns information regarding packages and versioning for NAP release -// version 3.9. -func NAPRelease3_9() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-26+3.780.1-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-26+3.780.1-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_26+3.780.1-1~buster_amd64.deb", - Redhat7: "app-protect-26+3.780.1-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-26+3.780.1-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_26+3.780.1-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_26+3.780.1-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.780.1", - NAPCompiler: "10.16.5", - NAPEngine: "10.16.5", - NAPPlugin: "3.780.1", - NAPPlusModule: "26+3.780.1", - NAPRelease: "3.9", - NginxPlus: "26", - }, - } -} - -// NAPRelease3_8 returns information regarding packages and versioning for NAP release -// version 3.8. -func NAPRelease3_8() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-25+3.760.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-25+3.760.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_25+3.760.0-1~buster_amd64.deb", - Redhat7: "app-protect-25+3.760.0-1.el7.ngx.x86_64.rpm", - Redhat8: "app-protect-25+3.760.0-1.el8.ngx.x86_64.rpm", - Ubuntu1804: "app-protect_25+3.760.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_25+3.760.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.760.0", - NAPCompiler: "9.15.0", - NAPEngine: "9.15.0", - NAPPlugin: "3.760.0", - NAPPlusModule: "25+3.760.0", - NAPRelease: "3.8", - NginxPlus: "25", - }, - } -} - -// NAPRelease3_7 returns information regarding packages and versioning for NAP release -// version 3.7. -func NAPRelease3_7() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-25+3.733.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-25+3.733.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_25+3.733.0-1~buster_amd64.deb", - Redhat7: "app-protect-25+3.733.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_25+3.733.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_25+3.733.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.733.0", - NAPCompiler: "9.15.0", - NAPEngine: "9.15.0", - NAPPlugin: "3.733.0", - NAPPlusModule: "25+3.733.0", - NAPRelease: "3.7", - NginxPlus: "25", - }, - } -} - -// NAPRelease3_6 returns information regarding packages and versioning for NAP release -// version 3.6. -func NAPRelease3_6() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "", - AmazonLinux2: "app-protect-25+3.671.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-25+3.671.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_25+3.671.0-1~buster_amd64.deb", - Redhat7: "app-protect-25+3.671.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_25+3.671.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_25+3.671.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.671.0", - NAPCompiler: "8.12.1", - NAPEngine: "8.12.1", - NAPPlugin: "3.671.0", - NAPPlusModule: "25+3.671.0", - NAPRelease: "3.6", - NginxPlus: "25", - }, - } -} - -// NAPRelease3_5 returns information regarding packages and versioning for NAP release -// version 3.5. -func NAPRelease3_5() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.639.0-r1.apk", - AmazonLinux2: "app-protect-24+3.639.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-24+3.639.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.639.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.639.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.639.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.639.0-1~focal_amd64.de", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.639.0", - NAPCompiler: "8.7.4", - NAPEngine: "8.7.4", - NAPPlugin: "3.639.0", - NAPPlusModule: "24+3.639.0", - NAPRelease: "3.5", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_4 returns information regarding packages and versioning for NAP release -// version 3.4. -func NAPRelease3_4() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.612.0-r1.apk", - AmazonLinux2: "app-protect-24+3.612.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-24+3.612.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.612.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.612.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.612.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.612.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.612.0", - NAPCompiler: "7.19.6", - NAPEngine: "7.19.6", - NAPPlugin: "3.612.0", - NAPPlusModule: "24+3.612.0", - NAPRelease: "3.4", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_3 returns information regarding packages and versioning for NAP release -// version 3.3. -func NAPRelease3_3() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.583.0-r1.apk", - AmazonLinux2: "app-protect-24+3.583.0-1.el7.ngx.x86_64.rpm", - Centos7: "app-protect-24+3.583.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.583.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.583.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.583.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.583.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.583.0", - NAPCompiler: "7.7.7", - NAPEngine: "7.7.7", - NAPPlugin: "3.583.0", - NAPPlusModule: "24+3.583.0", - NAPRelease: "3.3", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_2 returns information regarding packages and versioning for NAP release -// version 3.2. -func NAPRelease3_2() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-24.3.512.0-r1.apk", - AmazonLinux2: "", - Centos7: "app-protect-24+3.512.0-1.el7.ngx.x86_64.rpm", - Debian9: "", - Debian10: "app-protect_24+3.512.0-1~buster_amd64.deb", - Redhat7: "app-protect-24+3.512.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_24+3.512.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_24+3.512.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.512.0", - NAPCompiler: "6.64.2", - NAPEngine: "6.64.2", - NAPPlugin: "3.512.0", - NAPPlusModule: "24+3.512.0", - NAPRelease: "3.2", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_1 returns information regarding packages and versioning for NAP release -// version 3.1. -func NAPRelease3_1() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-23.3.462.0-r1.apk", - AmazonLinux2: "", - Centos7: "app-protect-23+3.462.0-1.el7.ngx.x86_64.rpm", - Debian9: "app-protect_23+3.462.0-1~stretch_amd64.deb", - Debian10: "app-protect_23+3.462.0-1~buster_amd64.deb", - Redhat7: "app-protect-23+3.462.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_23+3.462.0-1~bionic_amd64.deb", - Ubuntu2004: "app-protect_23+3.462.0-1~focal_amd64.deb", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.462.0", - NAPCompiler: "6.53.1", - NAPEngine: "6.53.1", - NAPPlugin: "3.462.0", - NAPPlusModule: "23+3.462.0", - NAPRelease: "3.1", - NginxPlus: "24", - }, - } -} - -// NAPRelease3_0 returns information regarding packages and versioning for NAP release -// version 3.0. -func NAPRelease3_0() NAPRelease { - return NAPRelease{ - NAPPackages: NAPReleasePackages{ - Alpine310: "app-protect-23.3.332.0-r1.apk", - AmazonLinux2: "", - Centos7: "app-protect-23+3.332.0-1.el7.ngx.x86_64.rpm", - Debian9: "app-protect_23+3.332.0-1~stretch_amd64.deb", - Debian10: "app-protect_23+3.332.0-1~buster_amd64.deb", - Redhat7: "app-protect-23+3.332.0-1.el7.ngx.x86_64.rpm", - Redhat8: "", - Ubuntu1804: "app-protect_23+3.332.0-1~bionic_amd64.deb", - Ubuntu2004: "", - }, - NAPCompilerPackages: NAPReleasePackages{}, - NAPEnginePackages: NAPReleasePackages{}, - NAPPluginPackages: NAPReleasePackages{}, - NAPPlusModulePackages: NAPReleasePackages{}, - VersioningDetails: NAPVersioningDetails{ - NAPBuild: "3.332.0", - NAPCompiler: "6.3.6", - NAPEngine: "6.3.6", - NAPPlugin: "3.332.0", - NAPPlusModule: "23+3.332.0", - NAPRelease: "3.0", - NginxPlus: "23", - }, - } -} - -func NAPReleaseUnmappedBuild(buildVersion string) NAPRelease { +func ReleaseUnmappedBuild(buildVersion string) NAPRelease { return NAPRelease{ NAPPackages: NAPReleasePackages{}, NAPCompilerPackages: NAPReleasePackages{}, @@ -474,7 +9,7 @@ func NAPReleaseUnmappedBuild(buildVersion string) NAPRelease { NAPPlusModulePackages: NAPReleasePackages{}, VersioningDetails: NAPVersioningDetails{ NAPBuild: buildVersion, - NAPRelease: "build-" + buildVersion, + NAPRelease: buildVersion, }, } } diff --git a/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go b/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go index cab3f517d..dfb5f1526 100644 --- a/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go +++ b/vendor/github.com/nginx/agent/sdk/v2/proto/events/event.pb.go @@ -123,6 +123,7 @@ func (m *Metadata) GetCategory() string { type Event struct { Metadata *Metadata `protobuf:"bytes,1,opt,name=Metadata,proto3" json:"metadata"` // Types that are valid to be assigned to Data: + // // *Event_ActivityEvent // *Event_SecurityViolationEvent Data isEvent_Data `protobuf_oneof:"data"`