Skip to content

apparmor: use "filepath" instead of "path", and fix linting (gosec)#11

Open
thaJeztah wants to merge 3 commits intomainfrom
apparmor_linting
Open

apparmor: use "filepath" instead of "path", and fix linting (gosec)#11
thaJeztah wants to merge 3 commits intomainfrom
apparmor_linting

Conversation

@thaJeztah
Copy link
Member

  Error: /home/runner/work/profiles/profiles/apparmor/apparmor.go:82:16: G703: Path traversal via taint analysis (gosec)
        _ = os.Remove(tmpFile.Name())
                     ^
  Error: /home/runner/work/profiles/profiles/apparmor/apparmor.go:129:7: G204: Subprocess launched with variable (gosec)
    c := exec.Command("apparmor_parser", "-Kr", profilePath)
         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

// Install to a temporary directory.
tmpFile, err := os.CreateTemp("", name)
tmpFile, err := os.CreateTemp("", "apparmor-profile-")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a need for the temp-file name to match the profile name; it's just a temporary file we use to load the profile?

@thaJeztah thaJeztah force-pushed the apparmor_linting branch 2 times, most recently from 6c6a783 to 73ab97b Compare February 19, 2026 15:58
      Error: /home/runner/work/profiles/profiles/apparmor/apparmor.go:82:16: G703: Path traversal via taint analysis (gosec)
            _ = os.Remove(tmpFile.Name())
                         ^
      Error: /home/runner/work/profiles/profiles/apparmor/apparmor.go:129:7: G204: Subprocess launched with variable (gosec)
        c := exec.Command("apparmor_parser", "-Kr", profilePath)
             ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

@vvoland ptal; follow-up is in #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant