Commit graph

51 commits

Author SHA1 Message Date
ohemorange
23e6c28d80 Allow Nginx to insert include files with comments inside (#4666)
* add failing test case

* allow include files to insert comments

* lint
2017-05-15 15:30:50 -07:00
ohemorange
7016874243 Switch to using include directive for Nginx constants (#4557)
* Switch to using include directive for Nginx constants

* remove deprecated comment

* give better error message when attempting to insert an existing directive

* make code more readable

* add docstrings

* allow a duplicated directive if it's identical

* comment out precisely repeated directives

* add comments
2017-05-02 17:56:56 -07:00
ohemorange
1611df4120 Allow empty nginx blocks (#4555)
* modify test config file to allow valid config that fails to parse in parser.py

* make failing tests pass by fixing the problem
2017-04-26 18:44:06 -07:00
Erica Portnoy
7be2e79025 Fix nginx parser (#4296)
* rewrite nginx parser to allow everything that nginx does

* also make changes in tls_sni_01.py

* add test case with

* allow embedded variables

* allow empty ${} variable

* fix quotes

* un-special case if

* update all tests to reflect current parsing

* escape in QuotedString after merge

* add test cases for variable weirdness that are almost certainly nginx bugs

* update regex for correct variable rules

* close paren doesn't invoke last_space

* Make test file valid Nginx syntax
2017-03-24 19:45:53 -07:00
Yen Chi Hsuan
4cad594b4b Python 3 compatibility for all tests (#4358) 2017-03-17 13:10:02 -07:00
Erica Portnoy
e5909d379c Don't crash on listen unix: (#4259)
Fixes #4225.

* don't crash on listen unix:

* correctly merge #4221
2017-02-27 13:35:29 -08:00
silverwind
b1a4280519 Show error details for the nginx config parser (#4221)
Nginx parser errors now include helpful details on where parsing has
actually failed.

Related: https://github.com/certbot/certbot/issues/3798
2017-02-22 18:50:56 -08:00
Erica Portnoy
f0a7bb0e33 Mark Nginx vhosts as ssl when any vhost is on ssl at that address (#3856)
* Move parse_server to be a method of NginxParser

* add super equal method to more correctly check addr equality in nginx should we support ipv6 in nginx in the future

* add addr:normalized_tuple method

* mark addresses listening sslishly due to another server block listening sslishly on that address

* test turning on ssl globally

* add docstring

* lint and remove extra file
2016-12-05 19:17:04 -08:00
Nick Fong
dd8772b608 Remove get_all_certs_keys() from Apache and Nginx (#3768)
- Remove get_all_certs_keys() implementation in
    - certbot-apache/certbot_apache/configurator.py
- Remove corresponding tests for get_all_certs_keys() in
    - certbot-apache/certbot_apache/tests/configurator_test.py
- Remove get_all_certs_keys() implementation in
    - certbot-nginx/certbot_nginx/configurator.py
    - certbot-nginx/certbot_nginx/parser.py
- Remove corresponding tests for get_all_certs_keys() in:
    - certbot-nginx/certbot_nginx/tests/configurator_test.py
    - certbot-nginx/certbot_nginx/tests/parser_test.py

Resolves #3762
2016-11-08 17:19:05 -08:00
Erica Portnoy
df10a6431b Don't re-add redirects if one exists (#3751)
* Don't re-add redirects if one exists

* coverage

* make coverage happy

* don't re-add comment, and clean code
2016-11-07 15:48:46 -08:00
Erica Portnoy
4bc3c747cb Mark parsed Nginx addresses as listening sslishly when an ssl on directive is included in the server block. (#3607) 2016-10-10 19:04:35 -07:00
Erica Portnoy
c9bc034512 Update Nginx redirect enhancement process to modify appropriate blocks (#3546)
* Cache the vhost we find during nginx deployment for OCSP enhancement.

* Refactor to pass domain into enhancement functions

* Add https redirect to most name-matching block listening non-sslishly.

* Redirect enhancement chooses the vhost most closely matching target_name that is listening to port 80 without using ssl.

* Add default listen 80 directive when it is implicitly defined
2016-09-29 16:16:07 -07:00
Erica Portnoy
9f2dfc15fe Restructure how Nginx parser re-finds vhosts, and disable creating new server blocks. (#3528)
* Restructure add_server_directives to take a vhost as argument. This is the first step towards fixing vhost selection in nginx.

* Save path to vhost in file while parsing in get_vhosts().

* Disable creating a new server block when no names match.

* Make parser select vhost based on information in the vhost it found previously, rather than searching again for a match.

* Make add_server_directives update the passed vhost

* Update boulder config to pass test

* Add testing code for the _do_for_subarray function

* documentation and formatting updates
2016-09-26 13:13:29 -07:00
Peter Eckersley
df61b0e349 Check for comments more accurately 2016-08-18 13:56:15 -07:00
Brad Warren
449487e8cb Catch all pyparsing exceptions 2016-08-16 19:34:16 -07:00
Brad Warren
465aa38143 Revert "Catch all pyparsing exceptions"
This reverts commit 7fb5cf1cf5.
2016-08-16 19:33:19 -07:00
Brad Warren
76c2fe579a Make _comment_directive more defensive 2016-08-16 18:30:45 -07:00
Brad Warren
671d7ee194 Fix up COMMENT constants 2016-08-16 17:45:43 -07:00
Brad Warren
3d4f822be0 Handle case where block is empty -- not sure if it ever happens, but let's not error out unnecessarily 2016-08-16 16:41:23 -07:00
Brad Warren
ae23800e53 Comment code that confused bmw 2016-08-16 16:37:40 -07:00
Brad Warren
7fb5cf1cf5 Catch all pyparsing exceptions 2016-08-16 15:46:31 -07:00
Peter Eckersley
b5fa0fbad7 This is reportedly the correct magic 2016-08-08 18:08:11 -07:00
Peter Eckersley
f0c2ed3059 Lint, improve coverage, rm unused code 2016-08-08 15:45:49 -07:00
Peter Eckersley
cdc894601c Tolerate our own added newlines 2016-08-05 15:36:40 -07:00
Peter Eckersley
3a2df72bce Add newlines to the ends of blocks more correctly 2016-08-05 15:36:24 -07:00
Peter Eckersley
61b81b877d Merge remote-tracking branch 'origin/master' into no-conflicting-declarations3 2016-07-29 17:28:29 -07:00
Peter Eckersley
e1f560dca3 Neaten 2016-07-26 17:23:24 -07:00
Ville Skyttä
c7b89c334b Use logger.warning instead of deprecated warn 2016-07-22 09:54:28 +03:00
Peter Eckersley
e5cb04ee7d A couple of fixes 2016-07-21 13:26:57 -07:00
Brad Warren
2ce5b195e5 check certbot 2016-07-18 18:23:54 -07:00
Brad Warren
ed4fc9d2f7 call _comment_directive 2016-07-18 18:20:21 -07:00
Brad Warren
5dd8f70e56 better newline logic 2016-07-18 18:19:14 -07:00
Brad Warren
bd21325fcd newline logic 2016-07-18 18:12:44 -07:00
Brad Warren
aa33c0fa83 does it work? 2016-07-18 15:33:28 -07:00
Brad Warren
5d7ef49fac _add_directive cleanup 2016-07-18 15:25:09 -07:00
Brad Warren
dbb2398270 Add _comment_spaced_block 2016-07-15 09:25:12 -07:00
Brad Warren
9c915b0ae4 Fix tests 2016-07-14 18:15:01 -07:00
Brad Warren
6b639679e8 Merge branch 'master' into no-conflicting-declarations 2016-07-14 17:26:39 -07:00
Peter Eckersley
6017a6cb6d Only write nginx config files if we've modified them 2016-06-27 12:44:36 -07:00
Peter Eckersley
db66050a7a Make atomicity comment more accurate 2016-06-23 11:41:31 -07:00
Peter Eckersley
098d23ac98 Comment a couple of things 2016-06-21 15:33:57 -07:00
Peter Eckersley
884b21ffbe fix docstring typo 2016-06-21 15:11:32 -07:00
Peter Eckersley
e4f88506cc Fix TLS_SNI & associated tests 2016-06-18 14:52:07 -07:00
Peter Eckersley
efd1ff46c6 Lint 2016-06-16 18:18:33 -07:00
Peter Eckersley
b82ebd9180 Fix desyncronisation with .spaced when modifying sublists
- we now actually write directives again!
2016-06-16 17:17:13 -07:00
Peter Eckersley
2cbd680bd5 Hide .spaced from users outside nginxparser.py 2016-06-15 17:36:53 -07:00
Peter Eckersley
4f46289c1b Start cleanup 2016-06-15 17:26:38 -07:00
Peter Eckersley
5e59b8ad46 Woohoo! it works 2016-06-15 16:42:47 -07:00
Peter Eckersley
8147c671e4 Now handles some conf files in whitespace-preserving mode
(but not all of them)
2016-06-08 17:52:35 -07:00
Peter Eckersley
9be5f7d7d9 Further WIP 2016-06-07 17:17:17 -07:00