Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

func: Allow custom paths to be added the the getter landlock #20349

Merged
merged 2 commits into from
Apr 11, 2024

Conversation

astudentofblake
Copy link
Contributor

Fixes: #20315

Copy link

hashicorp-cla-app bot commented Apr 10, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

This is excellent @astudentofblake! Just had a few minor nitpicks to clear up and then we can get this merged

@@ -9,6 +9,7 @@ import (

"github.com/dustin/go-humanize"
"github.com/hashicorp/nomad/nomad/structs/config"
"golang.org/x/exp/slices"
Copy link
Member

Choose a reason for hiding this comment

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

This can just be "slices" now; as of Go 1.21 I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've fixed these.

"golang.org/x/exp/slices" still exists in 2 other places outside this review, there seems to be a semgrep rule to catch these, but I didn't notice an error

"github.com/hashicorp/nomad/helper/pointer"
"github.com/shoenig/go-landlock"
"golang.org/x/exp/slices"
Copy link
Member

Choose a reason for hiding this comment

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

same, "slices"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Comment on lines 19 to 21
"p:a/b:r",
"p:a/c/drw",
"f:x/y:rw",
Copy link
Member

Choose a reason for hiding this comment

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

It's helpful for future maintainers when test data is at least plausible - in this case these paths are malformed (would trigger an error in landlock.ParsePath). Let's make these something that would be valid input (and in other tests).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These should all now contain reasonable data

Comment on lines 439 to 441
- `filesystem_isolation_extra_paths` `([]string: nil)` - Allow extra paths
in the filesystem isolation. Paths are specified in the form "[kind]:[mode]:[path]"
e.g. "f:r:/dev/urandom"
Copy link
Member

Choose a reason for hiding this comment

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

We should clarify what are kind and mode - kind must be f or d (file or directory), mode must be r, w, c, x (read, write, create, execute). And then let's add a second example of a directory and different permissions, like d:rx:/opt/bin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this with the extra info and tried to match the formatting.

@@ -209,6 +227,12 @@ func (a *ArtifactConfig) Validate() error {
return fmt.Errorf("disable_filesystem_isolation must be set")
}

for _, p := range a.FilesystemIsolationExtraPaths {
if _, err := landlock.ParsePath(p); err != nil {
return fmt.Errorf("filesystem_isolation_extra_paths contains invalid lockdown path %s", p)
Copy link
Member

Choose a reason for hiding this comment

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

let's swap the %s for %q so the user input stands out in the error

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

fix: more meaningful examples
fix: improve documentation
fix: quote error output
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @astudentofblake!

@shoenig shoenig merged commit 7b7ed12 into hashicorp:main Apr 11, 2024
18 of 20 checks passed
@shoenig shoenig added this to the 1.8.0 milestone Apr 11, 2024
philrenaud pushed a commit that referenced this pull request Apr 18, 2024
* func: Allow custom paths to be added the the getter landlock

Fixes: 20315

* fix: slices imports
fix: more meaningful examples
fix: improve documentation
fix: quote error output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

Allow custom files and directories to be added the the getter landlock
2 participants