Skip to content

apparmor: validateProfile: avoid failures on unrelated STDERR output - #46

Merged
vvoland merged 1 commit into
moby:mainfrom
thaJeztah:fix_util
Sep 25, 2026
Merged

vvoland merged 1 commit into
moby:mainfrom
thaJeztah:fix_util

Conversation

@thaJeztah

Copy link
Copy Markdown
Member

This was failing if a non-fatal warning was printed on STDERR;

=== RUN   TestGenerateProfileName
    apparmor_linux_test.go:325: parsed profile names = ["Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)" "foo\"bar,*?[ab]{c,d}^\\baz"], want ["foo\"bar,*?[ab]{c,d}^\\baz"]

Use Cmd.Output when validating generated profiles so that warnings written to stderr are not interpreted as declared profile names.

Preserve stderr from failed parser invocations in the test failure output.

updates aa2b3fd

This was failing if a non-fatal warning was printed on STDERR;

    === RUN   TestGenerateProfileName
        apparmor_linux_test.go:325: parsed profile names = ["Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)" "foo\"bar,*?[ab]{c,d}^\\baz"], want ["foo\"bar,*?[ab]{c,d}^\\baz"]

Use Cmd.Output when validating generated profiles so that warnings written to
stderr are not interpreted as declared profile names.

Preserve stderr from failed parser invocations in the test failure output.

updates aa2b3fd

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
cmd.Stdin = strings.NewReader(profile)

out, err := cmd.CombinedOutput()
out, err := cmd.Output()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🤦 I actually was considering this, then ... CI was happy and forgot about it 😂

@thaJeztah

Copy link
Copy Markdown
Member Author

@vvoland PTAL 🤗

@vvoland
vvoland merged commit f7ba7f7 into moby:main Sep 25, 2026
10 checks passed
@thaJeztah
thaJeztah deleted the fix_util branch September 25, 2026 12:57
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.

2 participants