Skip to content

fix: reject "." and ".." as trust store names - #1375

Open
ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/truststore-reject-dot-names
Open

ogulcanaydogan wants to merge 1 commit into
notaryproject:mainfrom
ogulcanaydogan:fix/truststore-reject-dot-names

Conversation

@ogulcanaydogan

Copy link
Copy Markdown
Contributor

Fixes #1374.

IsValidFileName accepted . and .., so notation cert delete --type ca --store .. --all resolved to the x509 directory and removed the trust stores of every type, and --store . removed the whole store type directory. The same check is used by cert add, show, generate-test and cleanup-test.

This rejects . and .. in IsValidFileName and hoists the regular expression out of the function. The error is the existing named store name needs to follow [a-zA-Z0-9_.-]+ format.

Tests:

  • TestIsValidFileName checks a table of names, including ., .., names containing dots and path separators.
  • TestCertDelete_DotNamedStoresDoNotTouchOtherStores runs deleteCerts with . and .. against a temporary config directory with two stores and checks that it returns an error and the certificates are still there.

Both fail without the change.

IsValidFileName accepted "." and "..", because both match the allowed
characters. The named store is joined to the trust store path, so
"notation cert delete --type ca --store .. --all" resolved to the x509
directory and removed the trust stores of every type, and "--store ."
removed the whole store type directory. The same check guards cert add,
show, generate-test and cleanup-test.

Reject "." and ".." in IsValidFileName and hoist the regular expression
out of the function.

Signed-off-by: Ogulcan Aydogan <ogulcanaydogan@gmail.com>
@codecov

codecov Bot commented Oct 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.16%. Comparing base (9ba75db) to head (3fa540a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1375      +/-   ##
==========================================
+ Coverage   80.10%   80.16%   +0.06%     
==========================================
  Files          68       68              
  Lines        3076     3076              
==========================================
+ Hits         2464     2466       +2     
+ Misses        403      402       -1     
+ Partials      209      208       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

cert: "." and ".." are accepted as trust store names and resolve outside the named store

1 participant