31 Commits
Author SHA1 Message Date
Adrien FerrandandBrad Warren 56f609d4f5 Fix unit tests on Windows (#7270)
Fixes #6850

This PR makes the last corrections needed to run all unit tests on Windows:

add a function to check if a hook is executable in a cross-platform compatible way
handle correctly the PATH surgery for Windows during hook execution
handle correctly an account compatibility over both ACMEv1 and ACMEv2
remove (finally!) the @broken_on_windows decorator.

* Fix account_tests

* Fix hook executable test

* Remove the temporary decorator @broken_on_windows

* Fix util_test

* No broken unit test on Windows anymore

* More elegant mock

* Fix context manager

* Adapt coverage

* Corrections

* Adapt coverage

* Forbid os.access
2019-08-01 10:39:46 -07:00
Felix LechnerandBrad Warren 641aba68b1 Ignore editor backups when running hooks. (#7109)
* Ignore editor backups when running hooks.

When processing hooks, certbot also runs editor backups even though
such files are outdated, clearly warranted correction and may quite
possibly be defective.

That behavior could lead to unexpected breakage, and perhaps even pose
security risks---for example, if a previous script was careless with
file permissions. As an aggravating factor, the backup runs after the
corrected version and could unintentionally override a fix the user
thought was properly implemented.

This commit causes editor backup files ending in tilde (~) to be
excluded when running hooks.

Additional information can be found here:

https://github.com/certbot/certbot/issues/7107
https://community.letsencrypt.org/t/editor-backup-files-executed-as-renewal-hooks/94750

* Add unit test for hook scripts with filenames ending in tilde.

* Provide changelog entry for not running hook scripts ending in tilde.

* Add Felix Lechner to the list of contributors.
2019-05-30 15:02:15 -07:00
Adrien FerrandandBrad Warren d5de24d9fc [Windows] Security model for files permissions - STEP 2 (#6895)
This PR is the second part of #6497 to ease the integration, following the new plan propose by @bmw here: #6497 (comment)

This PR creates the module certbot.compat.os, that delegates everything to os, and that will be the safeguard against problematic methods of the standard module. On top of that, a quality check wrapper is called in the lint tox environment. This wrapper calls pylint and ensures that standard os module is no used directly in the certbot codebase.

Finally local oldest requirements are updated to ensure that tests will take the new logic when running.

* Add executable permissions

* Add the delegate certbot.compat.os module, add check coding style to enforce usage of certbot.compat.os instead of standard os

* Load certbot.compat.os instead of os

* Move existing compat test

* Update local oldest requirements

* Import sys

* Update account_test.py

* Update os.py

* Update os.py

* Update local oldest requirements

* Implement the new linter_plugin

* Fix local oldest for nginx

* Remove check coding style

* Update linter_plugin.py

* Add several comments

* Update the setup.py

* Add documentation

* Update acme dependencies

* Update certbot/compat/os.py

* Update docs/contributing.rst

* Update linter_plugin.py

* Handle os.path. Simplify checker.

* Add a comment to a reference implementation

* Update changelog

* Fix module registering

* Update docs/contributing.rst

* Update config and changelog
2019-04-12 13:32:51 -07:00
Brad WarrenandJoona Hoikkala 31b4b8e57c Log the execution of manual hooks (#6788)
* Move logging to execute and fix tests.

* update changelog
2019-02-22 16:42:01 +02:00
Dmitry FigolandBrad Warren 36dfd06503 Prepare certbot module for mypy check untyped defs (#6005)
* Prepare certbot module for mypy check untyped defs

* Fix #5952

* Bump mypy to version 0.600 and fix associated bugs

* Fix pylint bugs after introducing mypy

* Implement Brad's suggestions

* Reenabling pylint and adding nginx mypy back
2018-05-18 06:28:17 -07:00
Brad WarrenandGitHub 356471cdf6 Add hook directories (#5151)
* Add hook dir constants

* Add hook dir properties to configuration

* test hook dir properties

* reuse certbot.util.is_exe

* Add certbot.hooks.list_hooks

* test list_hooks

* Run pre-hooks in directory

* Run deploy-hooks in directory

* Run post-hooks in directory

* Refactor and update certbot/tests/hook_test.py

* Add integration tests for hook directories

* Have Certbot create hook directories.

* document renewal hook directories

* Add --no-directory-hooks

* Make minor note about locale independent sorting
2017-10-03 13:52:02 -07:00
Brad Warren e94ee31a6f add hooks.deploy_hook 2017-06-30 10:24:00 -04:00
FabianandBrad Warren 2680879068 Print stdout when running a hook (#4167, #4487) (#4702) 2017-05-22 13:00:44 -07:00
dokazakiandBrad Warren 8011fb2879 Add mypy (#4386)
* Initial configuration of mypy in box, correction of base mypy errors.

* Move mypy install to toe

* Add pylint comments for typing imports.

* Remove typing module for Python 2.6 compatibility.
2017-03-18 19:10:10 -07:00
Alex BowersandBrad Warren 80326511bb Improve error reporting for hooks (#4235)
* Improve error reporting for hooks

* My bad

* Whitespace.
2017-03-03 10:28:05 -08:00
Brad WarrenandGitHub dc16013abe Correctly report when we skip hooks during renewal (#3977)
* Remove incorrect hook message

* Add generalized msg about skipping hooks

* Properly report when hooks were skipped

* Also print message about renew hook

* Change quotes to help OCD
2017-01-05 19:47:10 -05:00
Brad Warren dae9eee7d4 bool(len([])) == bool([]) 2017-01-04 12:58:59 -08:00
Brad Warren 458c7c8131 Use a set for pre_hook.already 2017-01-04 12:57:54 -08:00
Brad Warren d08cf89ad2 Remove all calls to which 2017-01-04 12:54:51 -08:00
Brad Warren 42b0188519 Merge branch 'master' into save-more-hooks 2017-01-04 12:24:53 -08:00
Brad WarrenandGitHub 39f5551305 Merge the manual and script plugins (#3890)
* Start of combined manual/script plugin

* Return str from hooks.execute, not bytes

* finish manual/script rewrite

* delete old manual and script plugins

* manually specify we want chall.token

* use consistent quotes

* specify chall for uri

* s/script/hook

* fix spacing on instructions

* remove unneeded response argument

* make achall more helpful

* simplify perform

* remove old test files

* add start of manual_tests

* fix ParseTest.test_help

* stop using manual_test_mode in cli tests

* Revert "make achall more helpful"

This reverts commit 54b01cea30.

* use bad response/validation methods on achalls

* simplify perform and cleanup environment

* finish manual tests

* Add HTTP manual hook integration test

* add manual http scripts

* Add manual DNS script integration test

* remove references to the script plugin

* they're hooks, not scripts

* add --manual-public-ip-logging-ok to integration tests

* use --pref-chall for dns integration

* does dns work?

* validate hooks

* test hook validation

* Revert "does dns work?"

This reverts commit 1224cc2961.

* busy wait in manual-http-auth

* remove DNS script test for now

* Fix challenge prefix and add trailing .

* Add comment about universal_newlines

* Fix typo from 0464ba2c4

* fix nits and typos

* Generalize HookCOmmandNotFound error

* Add verify_exe_exists

* Don't duplicate code in hooks.py

* Revert changes to hooks.py

* Use consistent hook error messages
2016-12-22 08:24:08 -08:00
Peter Eckersley ac17f98b0c Refactor post_hook storage during "renew" 2016-12-21 23:02:27 -08:00
Peter Eckersley 186a8c888f Path surgery makes sense for hooks that may be called from cron 2016-12-17 15:02:13 -08:00
Peter Eckersley 64daefea6b util.exe_exists and hooks._which were almost identical; merge them 2016-12-17 15:02:10 -08:00
Peter Eckersley de77dd74ad Unbreak repeated insertion logic 2016-12-15 17:31:32 -08:00
Peter Eckersley 33de782fba Make post hooks run in deterministic order 2016-12-15 17:28:16 -08:00
Peter Eckersley 0c2dc60484 Integration tests for hooks 2016-12-15 17:28:16 -08:00
Peter Eckersley 6f9abde894 Support intricate combinations of pre-hooks in different lineages 2016-12-15 17:28:16 -08:00
Peter Eckersley 0bea6c7350 Log when we run renew hooks (why weren't we doing this already?) 2016-12-15 17:28:16 -08:00
Peter Eckersley 876a760a91 Begin implementing pre / post-hook preservation 2016-12-15 17:28:16 -08:00
Joona HoikkalaandPeter Eckersley d741e684d0 Script plugin (#3521)
* Script plugin initial commit

* Fix auth script path

* Return correct responses

* Added DNS-01 support

* Report the challenge pref correctly

* Use config root from certbot constants rather than hardcoded

* Remove prehook and rename posthook to cleanup for clarity

* Refactoring

* Docs

* Refactoring

* Refactoring continued, working now

* Use global preferred-challenges argument in favor of local

* Added http-01 as fallback challenge if not defined

* Do not continue if auth script not defined

* Skip unnecessary steps when running

* Read config values from correct places

* Tests and minor fixes

* Make Python 2.6 happy again

* Added CERTBOT_AUTH_OUTPUT and better tests

* Lint & Py3 fixes

* Make Python 2.6 happy again

* Doc changes

* Refactor hook execute and reuse in script plugin

* Refactored hook validation

* Added long_description for plugin help text

* Refactored env var writing
2016-11-07 15:22:48 -08:00
Ville Skyttä c7b89c334b Use logger.warning instead of deprecated warn 2016-07-22 09:54:28 +03:00
Peter Eckersley 0294db7061 Merge pull request #2992 from certbot/post-hook
Only run post-hook if pre-hook was (or would have been, if it existed)
2016-05-18 16:31:00 -07:00
Marius Gedminas 321a806b91 Hook validation: skip leading spaces/newlines
Improves the situation with #3020 a bit.

Does nothing about other valid shell commands that the current
validation would reject:

  - shell builtins like --post-hook 'if [ -x /my/script ]; then /my/script; fi'
  - variable assignments like --post-hook 'ENV_VAR=value command'
  - comments
  - redirections like --post-hook '<infile command'
  - I'm sure I'm missing many other exciting possibilities
2016-05-18 11:57:50 +03:00
Peter Eckersley f4103bdbb3 post-hook only runs if pre-hook was (or would have been, if it existed) 2016-05-13 18:49:01 -07:00
Brad Warren 3961b70deb s/letsencrypt/certbot 2016-04-13 16:03:59 -07:00