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

Add error returns if command invalid in RunCommand #124 #125

Closed
wants to merge 1 commit into from

Conversation

u5surf
Copy link

@u5surf u5surf commented Sep 11, 2021

Please fill in the fields below to submit a pull request. The more
information that is provided, the better.

Fixes issue #:

Fixes #124

Description of pull request:

RunCommand has not validation to delegate to exec.Command, so I added simple validation that has checked cmdArgs length and nil.

Please verify and check that the pull request fulfills the following
requirements
:

  • Tests have been added for the bug fix or new feature
  • Docs have been added for the bug fix or new feature
    I consider that it is a trivial bug fix, so I'm not willing to write CHANGE.LOG
    If you feel like to write anything in docs, it is welcome for me about this :-)

@shibumi
Copy link
Collaborator

shibumi commented Sep 11, 2021

Hi @u5surf sorry, I just realized we were working on the same PR at the same time :D

@@ -240,6 +240,10 @@ command execution.
*/
func RunCommand(cmdArgs []string, runDir string) (map[string]interface{}, error) {

if cmdArgs == nil || len(cmdArgs) == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is actually not that easy.. this would lead to an error if cmdArgs is empty.
The in-toto python implementation allows empty cmdArgs, hence we need a fix in both functions. Like here:
https://github.com/in-toto/in-toto-golang/pull/126/files

@shibumi
Copy link
Collaborator

shibumi commented Sep 11, 2021

@u5surf do you want to adopt my PR in https://github.com/in-toto/in-toto-golang/pull/126/files?
My PR is missing more tests for the InTotoRun() function (testing link generation for empty cmdArgs). Do you want to work further on this or shall I? :)

See: https://github.com/in-toto/in-toto-golang/pull/126/files

@u5surf
Copy link
Author

u5surf commented Sep 12, 2021

@shibumi

My PR is missing more tests for the InTotoRun() function (testing link generation for empty cmdArgs). Do you want to work > further on this or shall I? :)

Close this PR.
I would like to add more tests for the InTotoRun() function base on your PR

@u5surf u5surf closed this Sep 12, 2021
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.

Potential bug in InTotoRun
2 participants