Skip to content

Ignore directories in secret repositories - #190

Open
Zhuyuyangyy wants to merge 1 commit into
HBNetwork:masterfrom
Zhuyuyangyy:fix/ignore-secret-subdirectories
Open

Zhuyuyangyy wants to merge 1 commit into
HBNetwork:masterfrom
Zhuyuyangyy:fix/ignore-secret-subdirectories

Conversation

@Zhuyuyangyy

Copy link
Copy Markdown

Problem

RepositorySecret opens every entry returned by os.listdir(source). If the secrets directory contains a subdirectory, construction raises IsADirectoryError, even when valid secret files are present alongside it.

Change

Skip entries that are not regular files before opening them. File symlinks still work because os.path.isfile follows symlinks. Normal file contents and read errors are otherwise unchanged.

Add a regression with a nested directory and a real db_password file: the repository must load the password and must not expose the directory as a secret.

Validation

The new regression fails on unchanged master with IsADirectoryError (focused run: 4 passed, 1 failed). After the patch, the focused suite has 5 passed and the full suite has 68 passed on Python 3.12. git show --check passes. Other Python versions were not tested.

AI assistance was used to investigate, implement, and test this change and draft this description.

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.

1 participant