-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: add build command #19
Conversation
Signed-off-by: Alessio Greggi <ale_grey_91@hotmail.it>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few suggestions
Why did you merge so quickly?
var ( | ||
inputDirectory string | ||
saveProfile bool | ||
profileName = "seccomp.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one could/should be a const
|
||
syscalls := make([]string, 0) | ||
for _, fileObj := range files { | ||
//fmt.Println("[" + fileObj.Name() + "]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a left behind debug
for _, fileObj := range files { | ||
//fmt.Println("[" + fileObj.Name() + "]") | ||
|
||
file, err := os.Open(inputDirectory + "/" + fileObj.Name()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use filepath.Join, do not convact things like that
} | ||
defer profileFile.Close() | ||
|
||
if err := profileFile.Chmod(0644); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err := profileFile.Chmod(0644); err != nil { | |
if err := profileFile.Chmod(0o644); err != nil { |
Use the octal notation
fmt.Printf("error setting permissions to %s: %v\n", profileFile.Name(), err) | ||
} | ||
// write to file | ||
fmt.Fprintln(profileFile, profile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Fprintln(profileFile, profile) | |
err := fmt.Fprintln(profileFile, profile) | |
if err != nil { | |
// log something | |
} |
defer profileFile.Close() | ||
|
||
if err := profileFile.Chmod(0644); err != nil { | ||
fmt.Printf("error setting permissions to %s: %v\n", profileFile.Name(), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we return, here?
|
||
profile, err := seccomp.BuildProfile(syscalls) | ||
if err != nil { | ||
fmt.Printf("error building seccomp profile: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No return here?
How could we continue if the profile cannot be built?
Hi @ccoVeille, |
I find bavk our conversation in my saved item. Did you fix all the things I reported? |
Closes #9
This PR introduce the new
build
command that allows the user to create seccomp profiles from the collected syscalls.