hashicorp / hashicorp/nomad

port label validation doesn't filter invalid characters

Open
#12,347 3 comments 0 reactions 0 assignees View on GitHub
stage/accepted theme/jobspec type/bug
Dominant language
Go
Stars
17k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
105

Description

### Nomad version
`Nomad v1.2.6 (a6c6b475db5073e33885377b4a5c733e1161020c)`

### Issue
Any character is accepted in the name parameter of the stanza network. The job is applied without syntax errors and Nomad's GUI even displays the name with special characters.

However, this should not be possible if we refer to the control [here](https://github.com/hashicorp/nomad/blob/main/jobspec/parse.go#L19).

On the other hand, Levant applies the check correctly and raises the syntax error.

![image](https://user-images.githubusercontent.com/29071937/159496720-70cd3e30-e1a6-422b-b0cc-d7e8b9bb05fd.png)

#### Expected Result
Port label does not conform to naming requirements ^[a-zA-Z0-9_]+$

#### Actual Result

No issue is raised. Job is applied without errors.

### Job file (if appropriate)

```
network {
port "myport,#!)'8" {
to = 8080
}
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in jobspec/parse.go, then trace how the network stanza's port label is parsed for the supplied job file. Verify the behavior with the example label containing special characters and ensure labels accept only the stated pattern, with invalid input producing a syntax error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.