Skip to content

Commit fbbe418

Browse files
committed
merge main
2 parents f958507 + ce964d4 commit fbbe418

22 files changed

+721
-384
lines changed

.github/workflows/mend.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Mend
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release-*
8+
tags:
9+
- "v[0-9]+.[0-9]+.[0-9]+*"
10+
paths-ignore:
11+
- docs/**
12+
pull_request:
13+
branches:
14+
- main
15+
- release-*
16+
paths-ignore:
17+
- docs/**
18+
19+
concurrency:
20+
group: ${{ github.ref_name }}-mend
21+
cancel-in-progress: true
22+
23+
permissions:
24+
contents: read
25+
26+
jobs:
27+
mend:
28+
if: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false) || (github.event_name == 'push' && github.event.repository.fork == false) }}
29+
uses: nginxinc/compliance-rules/.github/workflows/mend.yml@a27656f8f9a8748085b434ebe007f5b572709aad # v0.2
30+
secrets: inherit
31+
with:
32+
product_name: nginx-agent-v3_${{ github.ref_name }}
33+
project_name: nginx-agent-v3

.github/workflows/upload-release-assets.yml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pkgRepo:
77
description: "Source repository to pull packages from"
88
type: string
9-
default: ""
9+
default: "packages.nginx.org"
1010
pkgVersion:
1111
description: 'Agent version'
1212
type: string
@@ -57,20 +57,31 @@ jobs:
5757
with:
5858
ref: ${{ inputs.releaseBranch }}
5959

60-
- name: Azure Login
61-
if: ${{ inputs.uploadAzure == true }}
62-
uses: azure/login@8c334a195cbb38e46038007b304988d888bf676a # v2.0.0
63-
with:
64-
creds: ${{ secrets.AZURE_CREDENTIALS }}
65-
6660
- name: Download Packages
6761
run:
6862
|
6963
echo "Checking Packages in ${{inputs.pkgRepo}}/nginx-agent"
70-
PKG_REPO=${{inputs.pkgRepo}} CERT=${{secrets.PUBTEST_CERT}} KEY=${{secrets.PUBTEST_KEY}} DL=1 scripts/packages/package-check.sh ${{inputs.pkgVersion}}
64+
echo "${{secrets.PUBTEST_CERT}}" > pubtest.crt
65+
echo "${{secrets.PUBTEST_KEY}}" > pubtest.key
66+
PKG_REPO=${{inputs.pkgRepo}} CERT=pubtest.crt KEY=pubtest.key DL=1 scripts/packages/package-check.sh ${{inputs.pkgVersion}}
7167
find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}"
7268

73-
- name: Azure Upload Release Packages
69+
- name: GitHub Upload
70+
if: ${{ needs.vars.outputs.github_release == 'true' }}
71+
env:
72+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
73+
# clobber overwrites existing assets of the same name
74+
run: |
75+
gh release upload --clobber v${{ inputs.pkgVersion }} \
76+
$(find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}")
77+
78+
- name: Azure Login
79+
if: ${{ inputs.uploadAzure == true }}
80+
uses: azure/login@8c334a195cbb38e46038007b304988d888bf676a # v2.0.0
81+
with:
82+
creds: ${{ secrets.AZURE_CREDENTIALS }}
83+
84+
- name: Azure Upload
7485
if: ${{ inputs.uploadAzure == true }}
7586
uses: azure/CLI@965c8d7571d2231a54e321ddd07f7b10317f34d9 # v2.0.0
7687
with:
@@ -88,15 +99,6 @@ jobs:
8899
done
89100
90101
- name: Azure Logout
102+
if: ${{ inputs.uploadAzure == true }}
91103
run: |
92-
az logout
93-
if: always()
94-
95-
- name: GitHub Upload Release Assets
96-
if: ${{ needs.vars.outputs.github_release == 'true' }}
97-
env:
98-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99-
# clobber overwrites existing assets of the same name
100-
run: |
101-
gh release upload --clobber v${{ inputs.pkgVersion }} \
102-
$(find ${{inputs.pkgRepo}}/nginx-agent | grep -e "nginx-agent[_-]${{inputs.pkgVersion}}")
104+
az logout || exit 0

api/grpc/mpi/v1/command.pb.go

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/command.pb.validate.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/grpc/mpi/v1/command.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ message InstanceRuntime {
296296
// the process identifier
297297
int32 process_id = 1;
298298
// the binary path location
299-
string binary_path = 2 [(buf.validate.field).string.prefix = "/"];
299+
string binary_path = 2 [(buf.validate.field).string.pattern = "^\\/.*|^$"];
300300
// the config path location
301301
string config_path = 3 [(buf.validate.field).string.pattern = "^\\/.*|^$"];
302302
// more detailed runtime objects
@@ -362,6 +362,8 @@ message NGINXAppProtectRuntimeInfo {
362362
string attack_signature_version = 2;
363363
// Threat campaign version
364364
string threat_campaign_version = 3;
365+
// Enforcer engine version
366+
string enforcer_engine_version = 4;
365367
}
366368

367369
// A set of actions that can be performed on an instance

docs/proto/protos.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,7 @@ A set of runtime NGINX App Protect settings
10721072
| release | [string](#string) | | NGINX App Protect Release |
10731073
| attack_signature_version | [string](#string) | | Attack signature version |
10741074
| threat_campaign_version | [string](#string) | | Threat campaign version |
1075+
| enforcer_engine_version | [string](#string) | | Enforcer engine version |
10751076

10761077

10771078

internal/collector/otel_collector_plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const (
3737
// 2024-11-16T17:19:24+00:00 ---> Nov 16 17:19:24
3838
timestampConversionExpression = `'EXPR(let timestamp = split(split(body, ">")[1], " ")[0]; ` +
3939
`let newTimestamp = ` +
40-
`timestamp matches "(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})([+-]\\d{2}:\\d{2}|Z)" ` +
40+
`timestamp matches "(\\d{4})-(\\d{2})-(0\\d{1})T(\\d{2}):(\\d{2}):(\\d{2})([+-]\\d{2}:\\d{2}|Z)" ` +
4141
`? (let utcTime = ` +
4242
`date(timestamp).UTC(); utcTime.Format("Jan 2 15:04:05")) : date(timestamp).Format("Jan 02 15:04:05"); ` +
4343
`split(body, ">")[0] + ">" + newTimestamp + " " + split(body, " ", 2)[1])'`

internal/config/defaults.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ const (
6262
DefCollectorTLSCAPath = "/var/lib/nginx-agent/ca.pem"
6363
DefCollectorTLSSANNames = "127.0.0.1,::1,localhost"
6464

65-
DefCollectorBatchProcessorSendBatchSize = 8192
66-
DefCollectorBatchProcessorSendBatchMaxSize = 0
67-
DefCollectorBatchProcessorTimeout = 200 * time.Millisecond
65+
DefCollectorBatchProcessorSendBatchSize = 1000
66+
DefCollectorBatchProcessorSendBatchMaxSize = 1000
67+
DefCollectorBatchProcessorTimeout = 30 * time.Second
6868

6969
DefCollectorExtensionsHealthServerHost = "localhost"
7070
DefCollectorExtensionsHealthServerPort = 13133

internal/watcher/instance/instance_watcher_service.go

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,17 @@ type (
3939
}
4040

4141
InstanceWatcherService struct {
42-
processOperator process.ProcessOperatorInterface
43-
nginxConfigParser parser.ConfigParser
44-
executer exec.ExecInterface
45-
enabled *atomic.Bool
46-
agentConfig *config.Config
47-
instanceCache map[string]*mpi.Instance
48-
nginxConfigCache map[string]*model.NginxConfigContext
49-
instancesChannel chan<- InstanceUpdatesMessage
50-
nginxConfigContextChannel chan<- NginxConfigContextMessage
51-
nginxParser processParser
52-
nginxAppProtectProcessParser processParser
53-
cacheMutex sync.Mutex
42+
processOperator process.ProcessOperatorInterface
43+
nginxConfigParser parser.ConfigParser
44+
executer exec.ExecInterface
45+
enabled *atomic.Bool
46+
agentConfig *config.Config
47+
instanceCache map[string]*mpi.Instance
48+
nginxConfigCache map[string]*model.NginxConfigContext
49+
instancesChannel chan<- InstanceUpdatesMessage
50+
nginxConfigContextChannel chan<- NginxConfigContextMessage
51+
nginxParser processParser
52+
cacheMutex sync.Mutex
5453
}
5554

5655
InstanceUpdates struct {
@@ -75,16 +74,15 @@ func NewInstanceWatcherService(agentConfig *config.Config) *InstanceWatcherServi
7574
enabled.Store(true)
7675

7776
return &InstanceWatcherService{
78-
agentConfig: agentConfig,
79-
processOperator: process.NewProcessOperator(),
80-
nginxParser: NewNginxProcessParser(),
81-
nginxAppProtectProcessParser: NewNginxAppProtectProcessParser(),
82-
nginxConfigParser: parser.NewNginxConfigParser(agentConfig),
83-
instanceCache: make(map[string]*mpi.Instance),
84-
cacheMutex: sync.Mutex{},
85-
nginxConfigCache: make(map[string]*model.NginxConfigContext),
86-
executer: &exec.Exec{},
87-
enabled: enabled,
77+
agentConfig: agentConfig,
78+
processOperator: process.NewProcessOperator(),
79+
nginxParser: NewNginxProcessParser(),
80+
nginxConfigParser: parser.NewNginxConfigParser(agentConfig),
81+
instanceCache: make(map[string]*mpi.Instance),
82+
cacheMutex: sync.Mutex{},
83+
nginxConfigCache: make(map[string]*model.NginxConfigContext),
84+
executer: &exec.Exec{},
85+
enabled: enabled,
8886
}
8987
}
9088

@@ -265,7 +263,7 @@ func (iw *InstanceWatcherService) instanceUpdates(ctx context.Context) (
265263
) {
266264
iw.cacheMutex.Lock()
267265
defer iw.cacheMutex.Unlock()
268-
nginxProcesses, nginxAppProtectProcesses, err := iw.processOperator.Processes(ctx)
266+
nginxProcesses, err := iw.processOperator.Processes(ctx)
269267
if err != nil {
270268
return instanceUpdates, err
271269
}
@@ -280,10 +278,6 @@ func (iw *InstanceWatcherService) instanceUpdates(ctx context.Context) (
280278
instancesFound[instance.GetInstanceMeta().GetInstanceId()] = instance
281279
}
282280

283-
nginxAppProtectInstances := iw.nginxAppProtectProcessParser.Parse(ctx, nginxAppProtectProcesses)
284-
for _, instance := range nginxAppProtectInstances {
285-
instancesFound[instance.GetInstanceMeta().GetInstanceId()] = instance
286-
}
287281
newInstances, updatedInstances, deletedInstances := compareInstances(iw.instanceCache, instancesFound)
288282

289283
instanceUpdates.NewInstances = newInstances

internal/watcher/instance/instance_watcher_service_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestInstanceWatcherService_checkForUpdates(t *testing.T) {
2828
nginxConfigContext := testModel.ConfigContext()
2929

3030
fakeProcessWatcher := &processfakes.FakeProcessOperatorInterface{}
31-
fakeProcessWatcher.ProcessesReturns(nil, nil, nil)
31+
fakeProcessWatcher.ProcessesReturns(nil, nil)
3232

3333
fakeProcessParser := &instancefakes.FakeProcessParser{}
3434
fakeProcessParser.ParseReturns(map[string]*mpi.Instance{
@@ -44,7 +44,6 @@ func TestInstanceWatcherService_checkForUpdates(t *testing.T) {
4444
instanceWatcherService := NewInstanceWatcherService(types.AgentConfig())
4545
instanceWatcherService.processOperator = fakeProcessWatcher
4646
instanceWatcherService.nginxParser = fakeProcessParser
47-
instanceWatcherService.nginxAppProtectProcessParser = fakeProcessParser
4847
instanceWatcherService.nginxConfigParser = fakeNginxConfigParser
4948
instanceWatcherService.instancesChannel = instanceUpdatesChannel
5049
instanceWatcherService.nginxConfigContextChannel = nginxConfigContextChannel
@@ -132,7 +131,7 @@ func TestInstanceWatcherService_instanceUpdates(t *testing.T) {
132131
for _, test := range tests {
133132
t.Run(test.name, func(tt *testing.T) {
134133
fakeProcessWatcher := &processfakes.FakeProcessOperatorInterface{}
135-
fakeProcessWatcher.ProcessesReturns(nil, nil, nil)
134+
fakeProcessWatcher.ProcessesReturns(nil, nil)
136135

137136
fakeProcessParser := &instancefakes.FakeProcessParser{}
138137
fakeProcessParser.ParseReturns(test.parsedInstances)
@@ -144,7 +143,6 @@ func TestInstanceWatcherService_instanceUpdates(t *testing.T) {
144143
instanceWatcherService := NewInstanceWatcherService(types.AgentConfig())
145144
instanceWatcherService.processOperator = fakeProcessWatcher
146145
instanceWatcherService.nginxParser = fakeProcessParser
147-
instanceWatcherService.nginxAppProtectProcessParser = fakeProcessParser
148146
instanceWatcherService.instanceCache = test.oldInstances
149147
instanceWatcherService.executer = fakeExec
150148

0 commit comments

Comments
 (0)