Skip to content

Commit 1256fc4

Browse files
fix(mdm): resolve smoke test & go-lint
1 parent 0f315f0 commit 1256fc4

4 files changed

Lines changed: 24 additions & 13 deletions

File tree

.github/workflows/go.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@ permissions:
1212
jobs:
1313
lint:
1414
name: Lint
15-
runs-on: ubuntu-latest
15+
runs-on: macos-latest
1616
steps:
1717
- uses: actions/checkout@v4
1818
- uses: actions/setup-go@v5
1919
with:
20-
go-version: "1.24"
20+
go-version-file: go.mod
2121
- uses: golangci/golangci-lint-action@v6
2222
with:
2323
version: latest
24-
env:
25-
GOOS: darwin
2624

2725
test:
2826
name: Test
@@ -31,7 +29,7 @@ jobs:
3129
- uses: actions/checkout@v4
3230
- uses: actions/setup-go@v5
3331
with:
34-
go-version: "1.24"
32+
go-version-file: go.mod
3533
- run: make test
3634

3735
smoke:
@@ -42,5 +40,5 @@ jobs:
4240
- uses: actions/checkout@v4
4341
- uses: actions/setup-go@v5
4442
with:
45-
go-version: "1.24"
43+
go-version-file: go.mod
4644
- run: make smoke

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/step-security/dev-machine-guard
22

3-
go 1.25.3
3+
go 1.24

internal/detector/nodescan.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/base64"
66
"os"
77
"path/filepath"
8+
"strconv"
89
"strings"
910
"time"
1011

@@ -13,7 +14,18 @@ import (
1314
"github.com/step-security/dev-machine-guard/internal/progress"
1415
)
1516

16-
const maxProjectScanBytes = 500 * 1024 * 1024 // 500MB total limit
17+
const defaultMaxProjectScanBytes = 500 * 1024 * 1024 // 500MB total limit
18+
19+
// getMaxProjectScanBytes returns the size limit, overridable via
20+
// STEPSEC_MAX_NODE_SCAN_BYTES environment variable.
21+
func getMaxProjectScanBytes() int64 {
22+
if v := os.Getenv("STEPSEC_MAX_NODE_SCAN_BYTES"); v != "" {
23+
if n, err := strconv.ParseInt(v, 10, 64); err == nil && n > 0 {
24+
return n
25+
}
26+
}
27+
return defaultMaxProjectScanBytes
28+
}
1729

1830
// NodeScanner performs enterprise-mode node scanning (raw output, base64 encoded).
1931
type NodeScanner struct {
@@ -148,10 +160,11 @@ func (s *NodeScanner) scanPnpmGlobal(ctx context.Context) (model.NodeScanResult,
148160
}
149161

150162
// ScanProjects finds package.json files and runs the appropriate package manager list command.
151-
// Logs each found project and respects the 500MB size limit.
163+
// Logs each found project and respects the size limit (default 500MB, override via STEPSEC_MAX_NODE_SCAN_BYTES).
152164
func (s *NodeScanner) ScanProjects(ctx context.Context, searchDirs []string) []model.NodeScanResult {
153165
var results []model.NodeScanResult
154166
totalSize := int64(0)
167+
maxBytes := getMaxProjectScanBytes()
155168
count := 0
156169

157170
for _, dir := range searchDirs {
@@ -176,8 +189,8 @@ func (s *NodeScanner) ScanProjects(ctx context.Context, searchDirs []string) []m
176189
s.log.Progress(" Reached maximum of %d projects, stopping search", maxNodeProjects)
177190
return filepath.SkipAll
178191
}
179-
if totalSize > maxProjectScanBytes {
180-
s.log.Progress(" Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxProjectScanBytes)
192+
if totalSize > maxBytes {
193+
s.log.Progress(" Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxBytes)
181194
s.log.Progress(" Skipping remaining projects (prioritized by most recently modified)")
182195
return filepath.SkipAll
183196
}
@@ -196,8 +209,8 @@ func (s *NodeScanner) ScanProjects(ctx context.Context, searchDirs []string) []m
196209
r := s.scanProject(ctx, projectDir)
197210
resultSize := int64(len(r.RawStdoutBase64)) + int64(len(r.RawStderrBase64))
198211

199-
if totalSize+resultSize > maxProjectScanBytes {
200-
s.log.Progress(" Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxProjectScanBytes)
212+
if totalSize+resultSize > maxBytes {
213+
s.log.Progress(" Reached data size limit (%d bytes collected, limit: %d bytes)", totalSize, maxBytes)
201214
s.log.Progress(" Skipping remaining projects (prioritized by most recently modified)")
202215
return filepath.SkipAll
203216
}

stepsecurity-dev-machine-guard

16.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)