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

Image building runs for a long time when a long image name is used and the tag contains an illegal character #39617

Closed
wants to merge 1 commit into from

Conversation

wanger26
Copy link
Contributor

Change Summary

  • Simplify regular expression checking for validity of Image Reference to fix Catastrophic Backtracking for long custom images with illegal characters in tag

Issue

@scottfrederick
Copy link
Contributor

Thanks @wanger26. This change looked good to me, but a test somewhere else in the project failed. A test added to ImageReferenceTests like this passes without the change in this PR (as it should) but fails after the change:

	@Test
	void ofSimpleNameWithSingleCharacterSuffix() {
		ImageReference reference = ImageReference.of("ubuntu-a");
		assertThat(reference.getDomain()).isEqualTo("docker.io");
		assertThat(reference.getName()).isEqualTo("library/ubuntu-a");
		assertThat(reference.getTag()).isNull();
		assertThat(reference.getDigest()).isNull();
		assertThat(reference).hasToString("docker.io/library/ubuntu-a");
	}

A single character (lower-case alpha or numeric) after a - separator does not parse correctly.

Note that the RegEx, ImageReference and ImageReferenceTests are all (nearly) duplicated in the project. The RegEx and ImageReferenceTests classes will need the same change in both places.

Do you want to try to address this issue?

@scottfrederick scottfrederick added the status: waiting-for-feedback We need additional information before we can continue label Feb 19, 2024
@wanger26
Copy link
Contributor Author

@scottfrederick I can address the build issue as well as make the recommended adjustments. I am going to steal that test case too if you don't mind to make sure we get it right 💯

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 19, 2024
- Simplify regular expression checking for validity of Image Reference to fix Catastrophic Backtracking for long custom images with illegal characters in tag

spring-projects#39246
scottfrederick pushed a commit that referenced this pull request Feb 20, 2024
Update the regular expression used to parse Docker images references to
prevent catastrophic backtracking when images names are long and the
tag contains an illegal character.

See gh-39617
@scottfrederick scottfrederick added this to the 3.1.9 milestone Feb 20, 2024
@scottfrederick
Copy link
Contributor

Thanks very much @wanger26. The change has been merged along with a small polishing commit in c93acda.

@scottfrederick scottfrederick changed the title FIX - Catastrophic Backtracking for images with illegal char in tag Image building runs for a long time when a long image name is used and the tag contains an illegal character Feb 20, 2024
@scottfrederick scottfrederick added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants