Skip to content

Commit 58edbc0

Browse files
0sewa0wepudtStefanHauth
authored
Add unix.Umask (#52)
Co-authored-by: wepudt <[email protected]> Co-authored-by: Stefan Hauth <[email protected]>
1 parent d0defb4 commit 58edbc0

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN --mount=type=cache,target="/root/.cache/go-build" \
1919
-o ./build/_output/bin/dynatrace-bootstrapper
2020

2121
# platform is required, otherwise the copy command will copy the wrong architecture files, don't trust GitHub Actions linting warnings
22-
FROM --platform=$TARGETPLATFORM public.ecr.aws/dynatrace/dynatrace-codemodules:1.307.57.20250217-152612 AS codemodules
22+
FROM --platform=$TARGETPLATFORM public.ecr.aws/dynatrace/dynatrace-codemodules:1.311.70.20250416-094918 AS codemodules
2323

2424
# copy bootstrapper binary
2525
COPY --from=build /app/build/_output/bin /opt/dynatrace/oneagent/agent/lib64/
@@ -33,4 +33,4 @@ ENV USER_UID=1001 \
3333

3434
USER ${USER_UID}:${USER_UID}
3535

36-
ENTRYPOINT ["/opt/dynatrace/oneagent/agent/lib64/dynatrace-bootstrapper"]
36+
ENTRYPOINT ["/opt/dynatrace/oneagent/agent/lib64/dynatrace-bootstrapper"]

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/spf13/cobra v1.9.1
1111
github.com/stretchr/testify v1.10.0
1212
go.uber.org/zap v1.27.0
13+
golang.org/x/sys v0.32.0
1314
)
1415

1516
require (

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
2626
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
2727
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
2828
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
29+
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
30+
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
2931
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
3032
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
3133
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=

hack/testing/helm-sample/templates/deployment.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ spec:
4848
mountPath: /mnt/input
4949
containers:
5050
- image: docker.io/php:fpm-stretch
51+
securityContext:
52+
allowPrivilegeEscalation: false
53+
capabilities:
54+
drop:
55+
- ALL
56+
readOnlyRootFilesystem: false
57+
runAsNonRoot: true
58+
runAsUser: 101
59+
runAsGroup: 99
60+
seccompProfile:
61+
type: RuntimeDefault
5162
imagePullPolicy: Always
5263
livenessProbe:
5364
failureThreshold: 3
@@ -93,10 +104,6 @@ spec:
93104
- key: kubernetes.io/arch
94105
value: amd64
95106
effect: NoSchedule
96-
securityContext:
97-
runAsUser: 0
98-
runAsGroup: 0
99-
fsGroup: 2000
100107
terminationGracePeriodSeconds: 30
101108
imagePullSecrets:
102109
{{ .Values.image.pullSecrets }}

pkg/move/copy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
fsutils "github.com/Dynatrace/dynatrace-bootstrapper/pkg/utils/fs"
55
"github.com/go-logr/logr"
66
"github.com/spf13/afero"
7+
"golang.org/x/sys/unix"
78
)
89

910
type copyFunc func(log logr.Logger, fs afero.Afero, from, to string) error
@@ -13,6 +14,9 @@ var _ copyFunc = SimpleCopy
1314
func SimpleCopy(log logr.Logger, fs afero.Afero, from, to string) error {
1415
log.Info("starting to copy (simple)", "from", from, "to", to)
1516

17+
oldUmask := unix.Umask(0000)
18+
defer unix.Umask(oldUmask)
19+
1620
err := fsutils.CopyFolder(log, fs, from, to)
1721
if err != nil {
1822
log.Error(err, "error moving folder")

pkg/move/technologies.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/go-logr/logr"
1010
"github.com/pkg/errors"
1111
"github.com/spf13/afero"
12+
"golang.org/x/sys/unix"
1213
)
1314

1415
type Manifest struct {
@@ -40,6 +41,9 @@ func CopyByTechnology(log logr.Logger, fs afero.Afero, from string, to string, t
4041
return err
4142
}
4243

44+
oldUmask := unix.Umask(0000)
45+
defer unix.Umask(oldUmask)
46+
4347
for _, sourceFilePath := range filteredPaths {
4448
targetFilePath := filepath.Join(to, strings.Split(sourceFilePath, from)[1])
4549

0 commit comments

Comments
 (0)