-
Notifications
You must be signed in to change notification settings - Fork 2k
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
job, task group, and task IDs should not allow null characters #9020
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d4ef12e
documenting tests around null characters in job id, task group name, …
cgbaker 39c73f1
updated job validate to refute job/group/task IDs containing null cha…
cgbaker 5062e74
updated api tests wrt backwards compat on null chars in IDs
cgbaker b0c2e51
updated docs and validation to further prohibit null chars in region,…
cgbaker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -170,6 +170,30 @@ func TestJob_ValidateScaling(t *testing.T) { | |
require.Contains(mErr.Errors[0].Error(), "task group count must not be less than minimum count in scaling policy") | ||
} | ||
|
||
func TestJob_ValidateNullChar(t *testing.T) { | ||
assert := assert.New(t) | ||
|
||
// job id should not allow null characters | ||
job := testJob() | ||
job.ID = "id_with\000null_character" | ||
assert.Error(job.Validate(), "null character in job ID should not validate") | ||
|
||
// job name should not allow null characters | ||
job.ID = "happy_little_job_id" | ||
job.Name = "my job name with \000 characters" | ||
assert.Error(job.Validate(), "null character in job name should not validate") | ||
|
||
// task group name should not allow null characters | ||
job.Name = "my job" | ||
job.TaskGroups[0].Name = "oh_no_another_\000_char" | ||
assert.Error(job.Validate(), "null character in task group name should not validate") | ||
|
||
// task name should not allow null characters | ||
job.TaskGroups[0].Name = "so_much_better" | ||
job.TaskGroups[0].Tasks[0].Name = "ive_had_it_with_these_\000_chars_in_these_names" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😆 |
||
assert.Error(job.Validate(), "null character in task name should not validate") | ||
} | ||
|
||
func TestJob_Warnings(t *testing.T) { | ||
cases := []struct { | ||
Name string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It doesn't come up except when using the API, but Jobs have both a name and an ID. Should we be validating that
Job.Name
also doesn't contain a null char?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.
yeah, good point. i don't see any indexing there, but a quick test showed that null in
Name
put a docker job into a failing state:will update PR to include
Job.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.
ooh, in addition, the task drivers set the
NOMAD_DC
environment variable, which will fail if the node datacenter includes a null character 🤦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.
and region 🤦++