Skip to content

Validate project and image stream namespaces and names - #2351

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
liggitt:name_length_validation
May 22, 2015
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
liggitt:name_length_validation

Conversation

@liggitt

@liggitt liggitt commented May 19, 2015

Copy link
Copy Markdown
Contributor

To ensure we end up with valid image repository paths derived from ImageStreams, add the following validation:

  • Require Project names to be >= 2 characters on creation
  • Require ImageStream namespaces to be >= 2 characters
  • Require ImageStream namespace+'/'+name to be <= 255 characters
  • Require ImageStream names to be valid docker image repository names

To ensure we don't break updating an existing project/namespace that was created with a single character name:

  • Allow updating projects with names < 2 characters

Fixes #1232

@liggitt

liggitt commented May 19, 2015

Copy link
Copy Markdown
Contributor Author

@derekwaynecarr @ncdc PTAL

Comment thread pkg/image/api/validation/validation.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

<= 255, < 256

@liggitt

liggitt commented May 19, 2015

Copy link
Copy Markdown
Contributor Author

@ncdc imagestream comments addressed, ParseDockerImageReference validation added as well

Comment thread pkg/image/api/helper.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Each component must be at least 2 chars - meaning both ns and ref.Name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@liggitt

liggitt commented May 19, 2015

Copy link
Copy Markdown
Contributor Author

@ncdc updated to use docker constants/validation

Comment thread pkg/image/api/validation/validation.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is technically only relevant if the stream is using our internal registry. If spec.dockerImageRepository is set, it's ok to have a 1-char ns or name, since they won't be used in the push/pull spec. Not sure if it's worth making that distinction in the code, however.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since they can switch between internal/external post-creation, I'd rather keep this "strict" for now

@ncdc

ncdc commented May 19, 2015

Copy link
Copy Markdown
Contributor

ImageStream & DockerImageReference changes LGTM

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was only used in an examples test, removed the signature change

@liggitt

liggitt commented May 19, 2015

Copy link
Copy Markdown
Contributor Author

[test]

@openshift-bot

Copy link
Copy Markdown
Contributor

Comment thread pkg/image/api/helper.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Very scary.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this code is used by things where this is not a safe assumption.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We had the defaulting for registry/name but not for name. What code do we have that expects no namespace in a pull spec?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

----- Original Message -----

default:
    return ref, fmt.Errorf("the docker pull spec %q must be two or three
    segments separated by slashes", spec)
}
  • if len(ref.Namespace) == 0 {

We had the defaulting for registry/name but not for name. What code do we
have that expects no namespace in a pull spec?

Is library even present in v2?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm putting back the "library" defaulting where we had it before, and only validating what they passed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Library isn't a strict requirement in v2, but the Docker daemon still prepends library if you only specify foo

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm less concerned if they give us an invalid spec and it fails. The crux of this PR was preventing them from giving us namespace/imagestream pieces we would assemble into an invalid image repository

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm fine with keeping the library default the way it was originally

@liggitt

liggitt commented May 21, 2015

Copy link
Copy Markdown
Contributor Author

@smarterclayton, you ok with this now?

@liggitt

liggitt commented May 21, 2015

Copy link
Copy Markdown
Contributor Author

@ncdc @smarterclayton backed out the changes in ParseDockerImageReference to limit the scope of this PR. PTAL

@ncdc

ncdc commented May 21, 2015

Copy link
Copy Markdown
Contributor

LGTM

@liggitt

liggitt commented May 21, 2015

Copy link
Copy Markdown
Contributor Author

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/2052/) (Image: devenv-fedora_1595)

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin up to de47827

openshift-bot pushed a commit that referenced this pull request May 22, 2015
@openshift-bot
openshift-bot merged commit ccdb67d into openshift:master May 22, 2015
@liggitt
liggitt deleted the name_length_validation branch May 23, 2015 02:01
@ghost ghost mentioned this pull request May 26, 2015
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.

Add name length validations to project creation

5 participants