-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
caddyfile: Reject directives in the place of site addresses #6104
caddyfile: Reject directives in the place of site addresses #6104
Conversation
Yeah I think we should have a test that ensures Also, I'm realizing that we're not marking where in the Caddyfile (filename/linenum) the problem happened. I don't think that information is known at this point in the parser unfortunately. Maybe we should move these checks to be somewhere else where we still have the |
41dd354
to
5cde41d
Compare
5cde41d
to
daa0406
Compare
@francislavoie I get your point with the filename and line number but I am not entirely sure about where to move this new check since we need to loop through the block keys to determine if we are using a directive as a site address but we only have access to the |
I think we could either rework |
I think I like the second option better as it feels more intuitive to perform the check there. One issue is that we don't have access to the |
Ah right I forgot about that 😢 yeah it'll probably be better to pass down the tokens I guess. We can add some helper methods to ServerBlock to unwrap the tokens to a |
Tests are failing - looks like we need to add the |
7d1e18e
to
50172d0
Compare
@francislavoie I think we should be good to go now. I changed the location of that |
caddytest/integration/caddyfile_adapt/http_valid_directive_like_site_address.txt
Outdated
Show resolved
Hide resolved
50172d0
to
9d59719
Compare
All the feedback items from above should now be resolved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is great!
I made a few minor test adjustments, i.e. the error now asserts that the file/line is present, and I changed a couple other tests to fix some port conflicts that happened on my machine due to the tests using common ports (admin 2019 but I already have Caddy running, and 8080 is commonly used for some HTTP apps).
Resolves #6095
@francislavoie from my understanding, that's the only change needed but I might be wrong. Also, let me know if you think we need more tests.