Skip to content

Commit 63ff285

Browse files
Merge pull request #87 from step-security/bug-86
Bug 86
2 parents 7ba9129 + 75c5a80 commit 63ff285

File tree

6 files changed

+15
-7
lines changed

6 files changed

+15
-7
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ jobs:
3737
# Learn more about CodeQL language support at https://git.io/codeql-language-support
3838

3939
steps:
40-
- uses: step-security/harden-runner@917f7d59f22e82a5ddcaef409923426fd7aa6327
40+
- uses: step-security/harden-runner@v1
41+
with:
42+
egress-policy: audit
4143
- name: Checkout repository
4244
uses: actions/checkout@629c2de402a417ea7690ca6ce3f33229e27606a5
4345

.github/workflows/int.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ jobs:
1313
contents: read
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: step-security/harden-runner@917f7d59f22e82a5ddcaef409923426fd7aa6327
16+
- uses: step-security/harden-runner@v1
1717
with:
1818
allowed-endpoints:
1919
api.github.com:443
20-
beta.api.stepsecurity.io:443
2120
github.com:443
2221
int.api.stepsecurity.io:443
2322
pipelines.actions.githubusercontent.com:443

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ jobs:
1313
contents: write
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: step-security/harden-runner@917f7d59f22e82a5ddcaef409923426fd7aa6327
16+
- uses: step-security/harden-runner@v1
1717
with:
1818
allowed-endpoints:
19-
agent.api.stepsecurity.io:443
2019
api.github.com:443
2120
github.com:443
2221
goreleaser.com:443

.github/workflows/scorecard-analysis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ jobs:
2222
name: Scorecard analysis
2323
runs-on: ubuntu-latest
2424
steps:
25-
- uses: step-security/harden-runner@917f7d59f22e82a5ddcaef409923426fd7aa6327
25+
- uses: step-security/harden-runner@v1
26+
with:
27+
egress-policy: audit
28+
2629
- name: "Checkout code"
2730
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579
2831

eventhandler.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ func (eventHandler *EventHandler) GetToolChain(ppid, exe string) *Tool {
170170
tool := Tool{Name: filepath.Base(exe), SHA256: checksum}
171171

172172
// In some cases the process has already exited, so get from map first
173+
eventHandler.procMutex.Lock()
173174
parentProcess, found := eventHandler.ProcessMap[ppid]
175+
eventHandler.procMutex.Unlock()
174176

175177
if found {
176178
tool.Parent = eventHandler.GetToolChain(parentProcess.PPid, parentProcess.Exe)

netmon.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"context"
5+
"sync"
56
"time"
67

78
"github.com/florianl/go-nflog/v2"
@@ -17,6 +18,7 @@ type NetworkMonitor struct {
1718
Repo string
1819
ApiClient *ApiClient
1920
Status string
21+
netMutex sync.RWMutex
2022
}
2123

2224
var ipAddresses = make(map[string]int)
@@ -84,6 +86,7 @@ func (netMonitor *NetworkMonitor) handlePacket(attrs nflog.Attribute) {
8486
if ipv4Layer := packet.Layer(layers.LayerTypeIPv4); ipv4Layer != nil {
8587
// Get actual TCP data from this layer
8688
ipv4, _ := ipv4Layer.(*layers.IPv4)
89+
netMonitor.netMutex.Lock()
8790
_, found := ipAddresses[ipv4.DstIP.String()]
8891
if !found {
8992
ipAddresses[ipv4.DstIP.String()] = 1
@@ -93,7 +96,7 @@ func (netMonitor *NetworkMonitor) handlePacket(attrs nflog.Attribute) {
9396
ipv4.DstIP.String(), port, netMonitor.Status, timestamp, Tool{Name: Unknown, SHA256: Unknown})
9497
}
9598
}
96-
99+
netMonitor.netMutex.Unlock()
97100
}
98101

99102
}

0 commit comments

Comments
 (0)