From 717e5a89e2c0e46869053b0e4c55e968ceded020 Mon Sep 17 00:00:00 2001 From: Chris Baker <1675087+cgbaker@users.noreply.github.com> Date: Sat, 3 Oct 2020 22:07:18 +0000 Subject: [PATCH] updated job validate to refute job/group/task IDs containing null characters updated CHANGELOG and upgrade guide --- CHANGELOG.md | 1 + nomad/structs/structs.go | 6 ++++++ website/pages/docs/upgrade/upgrade-specific.mdx | 6 ++++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6eccde065ba..b5f0157f7e85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ IMPROVEMENTS: * jobspec: Lowered minimum CPU allowed from 10 to 1. [[GH-8996](https://github.com/hashicorp/nomad/issues/8996)] __BACKWARDS INCOMPATIBILITIES:__ + * core: job IDs, task group names, and task names are not allowed to contain null characters [[GH-9020](https://github.com/hashicorp/nomad/issues/9020)] * driver/docker: Tasks are now issued SIGTERM instead of SIGINT when stopping [[GH-8932](https://github.com/hashicorp/nomad/issues/8932)] BUG FIXES: diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index bce817474fd6..41f8adc4ae87 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -3943,6 +3943,8 @@ func (j *Job) Validate() error { mErr.Errors = append(mErr.Errors, errors.New("Missing job ID")) } else if strings.Contains(j.ID, " ") { mErr.Errors = append(mErr.Errors, errors.New("Job ID contains a space")) + } else if strings.Contains(j.ID, "\000") { + mErr.Errors = append(mErr.Errors, errors.New("Job ID contains a null chararacter")) } if j.Name == "" { mErr.Errors = append(mErr.Errors, errors.New("Missing job name")) @@ -5740,6 +5742,8 @@ func (tg *TaskGroup) Validate(j *Job) error { var mErr multierror.Error if tg.Name == "" { mErr.Errors = append(mErr.Errors, errors.New("Missing task group name")) + } else if strings.Contains(tg.Name, "\000") { + mErr.Errors = append(mErr.Errors, errors.New("Task group name contains null character")) } if tg.Count < 0 { mErr.Errors = append(mErr.Errors, errors.New("Task group count can't be negative")) @@ -6462,6 +6466,8 @@ func (t *Task) Validate(ephemeralDisk *EphemeralDisk, jobType string, tgServices // We enforce this so that when creating the directory on disk it will // not have any slashes. mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include slashes")) + } else if strings.Contains(t.Name, "\000") { + mErr.Errors = append(mErr.Errors, errors.New("Task name cannot include null characters")) } if t.Driver == "" { mErr.Errors = append(mErr.Errors, errors.New("Missing task driver")) diff --git a/website/pages/docs/upgrade/upgrade-specific.mdx b/website/pages/docs/upgrade/upgrade-specific.mdx index e8046e6ba4e7..ff2a9c0f1c02 100644 --- a/website/pages/docs/upgrade/upgrade-specific.mdx +++ b/website/pages/docs/upgrade/upgrade-specific.mdx @@ -24,6 +24,12 @@ When stopping tasks running with the Docker task driver, Nomad documents that a versions of Nomad would issue `SIGINT` instead. Starting again with Nomad v0.13.0 `SIGTERM` will be sent by default when stopping Docker tasks. +### Null characters in job, task group, and task IDs + +Starting with Nomad v0.13.0, job will fail validation if any of the following +contain null character: the job ID, the task group name, or the task name. Any +jobs meeting this requirement should be modified before an update to v0.13.0. + ## Nomad 0.12.0 ### `mbits` and Task Network Resource deprecation