Skip to content

Commit

Permalink
chore: Fix linux tracing in commandrun.
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Glastra <[email protected]>
  • Loading branch information
matglas committed Oct 2, 2024
1 parent 92968d0 commit ecacd4e
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions attestation/commandrun/tracing_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ const (
)

type ptraceContext struct {
parentPid int
mainProgram string
processes map[int]*ProcessInfo
exitCode int
hash []cryptoutil.DigestValue
environmentBlockList map[string]struct{}
parentPid int
mainProgram string
processes map[int]*ProcessInfo
exitCode int
hash []cryptoutil.DigestValue
sensitiveEnvList map[string]struct{}
}

func enableTracing(c *exec.Cmd) {
Expand All @@ -53,11 +53,11 @@ func enableTracing(c *exec.Cmd) {

func (r *CommandRun) trace(c *exec.Cmd, actx *attestation.AttestationContext) ([]ProcessInfo, error) {
pctx := &ptraceContext{
parentPid: c.Process.Pid,
mainProgram: c.Path,
processes: make(map[int]*ProcessInfo),
hash: actx.Hashes(),
environmentBlockList: r.environmentBlockList,
parentPid: c.Process.Pid,
mainProgram: c.Path,
processes: make(map[int]*ProcessInfo),
hash: actx.Hashes(),
sensitiveEnvList: r.sensitiveEnvList,
}

if err := pctx.runTrace(); err != nil {
Expand Down Expand Up @@ -201,7 +201,7 @@ func (p *ptraceContext) handleSyscall(pid int, regs unix.PtraceRegs) error {
if err == nil {
allVars := strings.Split(string(environ), "\x00")
filteredEnviron := make([]string, 0)
environment.FilterEnvironmentArray(allVars, p.environmentBlockList, func(_, _, varStr string) {
environment.FilterEnvironmentArray(allVars, p.sensitiveEnvList, map[string]struct{}{}, func(_, _, varStr string) {
filteredEnviron = append(filteredEnviron, varStr)
})

Expand Down

0 comments on commit ecacd4e

Please sign in to comment.