-
Notifications
You must be signed in to change notification settings - Fork 828
Fix unintentional file globbing during wildcard lookup #767
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
Conversation
Apologies for the re-pushes to trigger tests. It seems they can be a bit flaky with respect to timeouts? (Everything passes locally.) |
Actually there's only one test that is super flaky, the default certificate test : https://github.com/nginx-proxy/docker-letsencrypt-nginx-proxy-companion/blob/master/test/tests/default_cert/run.sh I haven't found why yet, I'm not sure it's just a timeout issue as I saw it happen locally too. Thanks for the fast PR, could you use / do what Shellcheck suggests before we merge it ? |
So it turns it was really fortunate you pushed back: the test cleanup was incomplete so subdomain.example.com was only passing because I had executed the tests with the broken build. I'm not sure how the GitHub actions were passing before; either they also don't clean up, or I'm getting tired and missing something. In any case, worth a complete re-review as that triggered a small number of related changes.
Done. |
You might have gone a bit too complex with the test, I think it should be way easier and probably sufficient to just test the enumerating function with a file that could glob in the current working dir. |
Something like # check the wildcard location enumeration function
docker exec "$le_container_name" bash -c \
'source /app/functions.sh; \
touch wrong.baz.example.com foo.bar.wrong; \
enumerate_wildcard_locations foo.bar.baz.example.com; \
rm wrong.baz.example.com foo.bar.wrong'
|
Interesting comment. Two rebuttals:
I would argue that the only new complexity was verifying the absence ( For subdomain.example.com, I can:
It sounds like your preference is the third point, which I can prep easily enough. |
Option 3 pushed. I think it might be the fewest number of changes to properly test this case. |
Matching globs are common because the script runs in the certs directory. The test uses a suffix match as the test domains don't include subdomains, although such cases should probably be considered. Fix the le3.wtf test. The existing add_location_configuration modifies "default"; a second add is not necessary. Fixes #763
Okay I think I might have issues wrapping my head around this. So yeah using a while read loop instead of a for loop actually fix the issue without using
Got that too.
Make sense now that I'm not under the false impression that testing Do you wish to roll back the change made to Don't bother force pushing to re trigger the test, I'll do it manually until they pass. |
Yeah, using set and restore was pretty obnoxious. (I did try to pipe to the read, but it wasn't working and here-string works so well...
I am around to your way of thinking, now: it's somewhat overkill to check both that it was added to the correct file and not added to the incorrect file. It would make the tests more robust when bad files are left around between test runs (what I originally ran into), but the automated tests and Happy to re-push if you ask again, but I'm pretty happy with this minimal set of changes.
Special powers are nice. |
Merged, thanks @LoganK ! |
Matching globs are common because the script runs in the certs
directory.
The test uses a suffix match as the test domains don't include
subdomains, although such cases should probably be considered.
Fix the le3.wtf test. The existing add_location_configuration modifies
"default"; a second add is not necessary.
Fixes #763