Skip to content

Commit 5d51956

Browse files
committed
add paths for NAP upon instance discovery
1 parent 852abe3 commit 5d51956

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ linters-settings:
340340
- google.golang.org/grpc/credentials
341341
- github.com/testcontainers/testcontainers-go
342342
- google.golang.org/grpc
343+
- github.com/nginx/agent/v3/api/grpc/mpi
343344
lll:
344345
# Max line length, lines longer will be reported.
345346
# '\t' is counted as 1 character by default, and can be changed with the tab-width option.

internal/watcher/instance/nginx-app-protect-instance-watcher.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
)
2121

2222
var (
23+
napDirPath = "/opt/app_protect"
2324
versionFilePath = "/opt/app_protect/VERSION"
2425
releaseFilePath = "/opt/app_protect/RELEASE"
2526
attackSignatureVersionFilePath = "/opt/app_protect/var/update_files/signatures/version"
@@ -49,6 +50,7 @@ type NginxAppProtectInstanceWatcher struct {
4950
}
5051

5152
func NewNginxAppProtectInstanceWatcher(agentConfig *config.Config) *NginxAppProtectInstanceWatcher {
53+
agentConfig.AllowedDirectories = append(agentConfig.AllowedDirectories, "/opt/app_protect")
5254
return &NginxAppProtectInstanceWatcher{
5355
agentConfig: agentConfig,
5456
filesBeingWatched: make(map[string]bool),

internal/watcher/instance/nginx-app-protect-instance-watcher_test.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package instance
88
import (
99
"context"
1010
"os"
11+
"slices"
1112
"testing"
1213
"time"
1314

@@ -95,6 +96,13 @@ func TestNginxAppProtectInstanceWatcher_Watch(t *testing.T) {
9596
},
9697
)
9798

99+
assert.True(t,
100+
slices.Contains(
101+
nginxAppProtectInstanceWatcher.agentConfig.AllowedDirectories,
102+
napDirPath,
103+
),
104+
)
105+
98106
go nginxAppProtectInstanceWatcher.Watch(ctx, instancesChannel)
99107

100108
t.Run("Test 1: New instance", func(t *testing.T) {
@@ -112,7 +120,6 @@ func TestNginxAppProtectInstanceWatcher_Watch(t *testing.T) {
112120
t.Fatalf("Timed out waiting for instance updates")
113121
}
114122
})
115-
116123
t.Run("Test 2: Update instance", func(t *testing.T) {
117124
_, err = enforcerEngineVersionFile.WriteAt([]byte("6.113.0"), 0)
118125
require.NoError(t, err)

0 commit comments

Comments
 (0)