Skip to content
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

1.0.0b1: chain of trust verification #25

Merged
merged 140 commits into from
Nov 15, 2016
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
3977b61
traceback -> log.critical(*args, exc_info=1)
escapewindow Oct 24, 2016
21f1527
clean up cot.py a bit
escapewindow Oct 14, 2016
5a7961f
check interactive docker worker
escapewindow Oct 14, 2016
8670ba3
classify_worker_type
escapewindow Oct 17, 2016
111e532
is_try
escapewindow Oct 17, 2016
e5377b1
docker image sha allowlists, hacky first version
escapewindow Oct 21, 2016
e181beb
start on built graph format
escapewindow Oct 21, 2016
dca4b23
get_task_id and get_run_id
escapewindow Oct 24, 2016
7e6f50b
possibly build task dict
escapewindow Oct 25, 2016
fc3fb89
removed the infinite loop!
escapewindow Oct 25, 2016
61c6006
docstrings; add unsignedArtifacts hack; clean up
escapewindow Oct 25, 2016
9165e66
100% task coverage
escapewindow Oct 25, 2016
bdc78f8
add 'decision' info to each cot graph dependency.
escapewindow Oct 25, 2016
3dace47
allow for passing valid artifact task ids to download_artifacts
escapewindow Oct 26, 2016
0bf2ebb
download_cot_artifacts
escapewindow Oct 26, 2016
268bdf5
verify_cot_signature
escapewindow Oct 26, 2016
18232e0
100% gpg coverage
escapewindow Oct 26, 2016
2268e37
wip before splitting out cot into objects
escapewindow Oct 26, 2016
3bf977b
ChainOfTrust and LinkOfTrust objects
escapewindow Oct 27, 2016
0c4503c
switch helper functions to using chain of trust object
escapewindow Oct 27, 2016
f9ed2a8
guess_task_type
escapewindow Oct 27, 2016
9df6353
get_artifact_url and is_try for links
escapewindow Oct 27, 2016
13bde6d
download_cot_artifacts
escapewindow Oct 27, 2016
3269a02
split scriptworker.cot into scriptworker.cot.generate and scriptworke…
escapewindow Oct 27, 2016
0edebd0
VALID_HASH_ALGORITHMS
escapewindow Oct 27, 2016
ef7fb3b
refactor validate_artifact_url with valid_artifact_rules
escapewindow Oct 27, 2016
22eddc7
100% client coverage
escapewindow Oct 27, 2016
87c464f
stub for decision task verification
escapewindow Oct 28, 2016
07575e4
audit_log_handler
escapewindow Oct 28, 2016
84968f1
cot.verify docstrings
escapewindow Oct 31, 2016
2cc5ee7
fixes; start build_chain_of_trust
escapewindow Oct 31, 2016
8d08e0c
move build_task_dependencies() call out of ChainOfTrust
escapewindow Oct 31, 2016
0689295
fix flake8; populate todos
escapewindow Oct 31, 2016
1bbadbf
get_valid_task_types -> function mapping.
escapewindow Oct 31, 2016
9b8dcb3
DEFAULT_CONFIG cleanup
escapewindow Nov 1, 2016
d810c14
move cot.verify constants into config
escapewindow Nov 1, 2016
af15b95
work around missing decision task chain of trust
escapewindow Nov 1, 2016
fe668b8
add testing script in temp location
escapewindow Nov 1, 2016
40d24a2
flake8 fix
escapewindow Nov 1, 2016
417ae7f
verify_task_types
escapewindow Nov 2, 2016
4f8aacb
some decision task tests; worker_class -> worker_impl
escapewindow Nov 2, 2016
9dfc48d
decision task tests, other than verifying child task defns
escapewindow Nov 2, 2016
3e3ce7d
verify task definitions match the full graph!
escapewindow Nov 3, 2016
ca8ee90
fix audit log; more decision task tests
escapewindow Nov 3, 2016
2e7f436
raise_on_messages; verify_build_tasks
escapewindow Nov 3, 2016
cb5e251
messages->errors; verify signing tasks; alphabetize and fix build env…
escapewindow Nov 3, 2016
8c6bea1
verify_*_tasks -> verify_*_task because we're only checking 1 at a time
escapewindow Nov 3, 2016
acf4617
docker-image task verification; some more docstrings
escapewindow Nov 3, 2016
29aedc8
flesh out docker-image workerType
escapewindow Nov 4, 2016
17ea146
test the decision task command
escapewindow Nov 4, 2016
dfc262a
make sure mach args are in order
escapewindow Nov 4, 2016
b0e9752
fix tests by pinning aiohttp to 1.0.5 for now
escapewindow Nov 4, 2016
3fd18d1
docker-image check written, but failing in real world test :(
escapewindow Nov 5, 2016
a125558
warn on docker-image sha test for now; add verify_cot.py
escapewindow Nov 5, 2016
9672be7
fix tests with aiohttp>=1.1.0
escapewindow Nov 5, 2016
4459635
comment updates
escapewindow Nov 5, 2016
eb9f243
stub for trace_back_to_tree
escapewindow Nov 7, 2016
c0ceea7
call it 0.10.0a1 until we're code complete
escapewindow Nov 7, 2016
f79e523
100% task coverage
escapewindow Nov 7, 2016
84715ca
context fixture -> scriptworker/test/__init__.py
escapewindow Nov 7, 2016
064c2b5
add cot verify test stub
escapewindow Nov 7, 2016
850107a
download all firefox cot artifacts before verifying
escapewindow Nov 7, 2016
58e9efa
specify bug 1315415 in comment
escapewindow Nov 7, 2016
ed0c32c
use less guessing
escapewindow Nov 8, 2016
8a1c2cf
fix
escapewindow Nov 8, 2016
ba4c821
load_json
escapewindow Nov 8, 2016
6cb8101
load_json: take an is_path arg
escapewindow Nov 8, 2016
5f477d9
flake8 fix
escapewindow Nov 8, 2016
4d3e193
start fleshing out trace_back_to_firefox_tree
escapewindow Nov 8, 2016
4e0763f
match_url_regex
escapewindow Nov 8, 2016
f3851c2
do use a callback for match_url_regex
escapewindow Nov 8, 2016
0ece35a
code complete?
escapewindow Nov 8, 2016
cdb6e3d
get verify_cot.py working
escapewindow Nov 8, 2016
e9b5042
fix flake8
escapewindow Nov 8, 2016
ef7da86
some cleanup
escapewindow Nov 8, 2016
8e9c083
test fix
escapewindow Nov 8, 2016
77a3ab4
start addressing review comments
escapewindow Nov 10, 2016
0dfa6d9
get rid of unused link.chain
escapewindow Nov 10, 2016
7981f03
bug 1316214 - allow for upstreamArtifacts
escapewindow Nov 9, 2016
ddbd5f1
another env var
escapewindow Nov 9, 2016
0da5329
0.10.0a2
escapewindow Nov 9, 2016
55db8f1
l10n cot verification. 0.10.0a3
escapewindow Nov 10, 2016
5520fe6
0.10.0a4: allow for more l10n env vars. already regretting this appro…
escapewindow Nov 10, 2016
a5a04c6
and version.json
escapewindow Nov 10, 2016
7b0cb0d
add more reclaimTask debug logging
escapewindow Nov 10, 2016
986cea4
0.10.0a5: reclaimTask debug logging
escapewindow Nov 10, 2016
3fe71e6
0.10.0a6 after rebasing on top of cot-verify 0dfa6d9
escapewindow Nov 10, 2016
0f48a8d
100% worker coverage
escapewindow Nov 10, 2016
2290c5d
load_json tests
escapewindow Nov 11, 2016
887fca8
100% task coverage
escapewindow Nov 11, 2016
3c790ca
16% coverage cot.verify
escapewindow Nov 11, 2016
fe39088
is_try: 21%
escapewindow Nov 11, 2016
91cd18e
get_link 22%
escapewindow Nov 11, 2016
9f8073b
use a link instead of magic mock in a couple places: 23%
escapewindow Nov 11, 2016
712dbe8
link.task, 25%
escapewindow Nov 11, 2016
8b04c77
raise_on_errors, audit_log_handler. 27%
escapewindow Nov 11, 2016
db5ea42
guess_worker_impl 29%
escapewindow Nov 11, 2016
0af23f1
get_valid_worker_impls
escapewindow Nov 11, 2016
a0c538e
get_task_type. 30%
escapewindow Nov 11, 2016
f9c8d16
check_interactive_docker_worker 32%
escapewindow Nov 11, 2016
b002cbb
clean verify_docker_image_sha; 35%
escapewindow Nov 11, 2016
03ed7e5
verify docker image sha full 37%
escapewindow Nov 11, 2016
721c3bb
find_task_dependencies. 41%
escapewindow Nov 11, 2016
ee7ce28
avoid triple-right-bracket for vim folding, while fixing flake8
escapewindow Nov 11, 2016
cd8260c
build_task_dependencies 46%
escapewindow Nov 11, 2016
428c5c4
download_cot 48%
escapewindow Nov 11, 2016
f05613a
download_cot_artifact 51%
escapewindow Nov 11, 2016
c37247f
download_cot_artifacts 53%
escapewindow Nov 11, 2016
ba4a7df
download_firefox_cot_artifacts 56%
escapewindow Nov 11, 2016
32725c2
verify_cot_signatures 60%
escapewindow Nov 11, 2016
86ae32f
verify_link_in_task_graph 65%
escapewindow Nov 11, 2016
b46c4c6
verify_firefox_decision_command 72%
escapewindow Nov 12, 2016
90ca846
verify_decision_task 76%
escapewindow Nov 12, 2016
9d85e31
fix flake8
escapewindow Nov 12, 2016
6c78802
verify_build_task 78%
escapewindow Nov 12, 2016
1514bd1
verify_docker_image_task 81%
escapewindow Nov 12, 2016
619c149
check_num_tasks, verify_signing_task 84%
escapewindow Nov 12, 2016
74e3afa
verify_task_types 85%
escapewindow Nov 12, 2016
5b5a05f
verify_worker_impls verify_scriptworker_task verify_docker_worker_tas…
escapewindow Nov 12, 2016
f28fe61
get_firefox_source_url 89%
escapewindow Nov 12, 2016
d54a46b
verify_chain_of_trust 92%
escapewindow Nov 12, 2016
f9fead8
100% coverage
escapewindow Nov 12, 2016
5678a61
100% test coverage without integration
escapewindow Nov 12, 2016
c8451c4
another try at 100% without integration tests
escapewindow Nov 12, 2016
fe0f60d
docker-image stopped specifying a payload command; support both for now
escapewindow Nov 14, 2016
7388741
bump to 0.10.0a7 for after i add more timeout logging
escapewindow Nov 14, 2016
5719fbe
scriptworker.cot.verify.audit_log_handler -> scriptworker.log.context…
escapewindow Nov 14, 2016
9cca0a6
status reporting logging
escapewindow Nov 14, 2016
dda7665
docker image env
escapewindow Nov 14, 2016
b660885
0.10.0a8
escapewindow Nov 14, 2016
a37cfbb
and version.json
escapewindow Nov 14, 2016
2a66733
add new docker-image sha
escapewindow Nov 14, 2016
b8c2520
address aiohttp.errors.ServerDisconnectedError on upload
escapewindow Nov 14, 2016
33cfd17
0.10.0a9
escapewindow Nov 14, 2016
121c474
reenable max_connections, since we're way over 30 for concurrent s3 u…
escapewindow Nov 14, 2016
c41bd07
start updating docs
escapewindow Nov 15, 2016
3f99634
new docs framework
escapewindow Nov 15, 2016
910c205
rst double backticks
escapewindow Nov 15, 2016
bb6138a
moar doc skeleton tweaks
escapewindow Nov 15, 2016
72cc1f0
1.0.0b1
escapewindow Nov 15, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ target/

# Vim
*.swp
*.swo

# TODO cleanup
secrets.json
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased
### Added
- `scriptworker.cot.verify` now verifies the chain of trust for the graph.
- `scriptworker.exceptions.CoTError` now marks chain of trust validation errors.
- `scriptworker.task.get_task_id`, `scriptworker.task.get_run_id`, `scriptworker.task.get_decision_task_id`, `scriptworker.task.get_worker_type`

### Changed
- config files are now yaml, to enable comments. `config_example.json` and `cot_config_example.json` have been consolidated into `scriptworker.yaml.tmpl`. `context.cot_config` items now live in `context.config`.
- `validate_artifact_url` now takes a list of dictionaries as rules, leading to more configurable url checking.
- `scriptworker.cot` is now `scriptworker.cot.generate`. The `get_environment` function has been renamed to `get_cot_environment`.
- `scriptworker.gpg.get_body` now takes a `verify_sig` kwarg.
- `download_artifacts` now takes `valid_artifact_task_ids` as a kwarg.

### Removed
- removed all references to `cot_config`
- removed the credential update, since puppet restarts scriptworker on config change.
- removed aiohttp max connections

## [0.9.0] - 2016-11-01
### Added
Expand Down
30 changes: 20 additions & 10 deletions requirements-prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ PyYAML==3.12 \
--hash=sha512:13733054619053893f4a8d75c1da020a87e1f697b007ab182be06b5b941b49c4cb3dc6f9ff131be6bc10fc727ad7334fa5401346f3a77140aed0f86280532fce \
--hash=sha512:5ff411ddbbf733ad52334015a04eb061998803ff94ad474ea2d534a713aa302cdfadde908ff2bb1dbd4f13e1a1fb99786f8dd1be1e061fcb6a7c0f471e41591f \
--hash=sha512:4ae6c5843688f45751ddb14a8b6f16f58b1f8a4805be430afa4035857b1826be95a8422395d64ac88282f9edd57f35fee5d1b6a4dab9093d47491d300d2079f3
aiohttp==1.0.5 \
--hash=sha512:520bbc3283de9f215ff57e3ab2e0f9255caef3bff65dd47d6ef846845732ec0ddb32488897241a0a03839e38569cb5a083300318df0e431677eeea1676c981d0 \
--hash=sha512:fd67c2a32b355e38aec5447af1decfa3efe91511a3d196c29c0f2b80fe208f11a89502e724468c3f23eb081875ced3044f1712db5f46cebe2abdc36bb4f88207 \
--hash=sha512:c18665e6ac0f71e8fcac35a66937f0226c8e4af4ddca2b15a27a77da3cf7172d3fe3f08ba202ca934aae27ea7676b8f9a0c2ee52acbb9d2f3bf922eafd89aab0 \
--hash=sha512:196a2f2604741b457a37529598c334aa6544923f979c4cf7394325a41e193953b926371332c06f30969cdc62ba9b19009f4bae8cb4bdcaa20f95410115a814af \
--hash=sha512:975f16c5c2eb3821ccbbd465acd6113b18c64a50f879143760e8fc457eb40548c29bccc215b55348c78e9de25c625a4aa94698e034fea3020a7d603ab8cf8264 \
--hash=sha512:d034ac08cc5c68753915df4dbe3e894a9fc09d423aff51c43d44eaafb0d12be84f8c21438ae29f6b828db9b586b952547becbd79d2209b4fbfd66d8dac4dad33 \
--hash=sha512:c0e1c4c65d2e3d4fce0c072e9876be0a39fee2e5ea727d5fdc9de361356f0744a5fe0a6b02e99358d2322144fa5dffbba1d966e24c4622070ffaf5f389f42198 \
--hash=sha512:a15ae9cd0d9409f6005b044249448fb079734517b1f2c93b898693657c2f2af389b924b30b36b4c03f91a599b2e85ffffa1e9ae458f6809f0a169e2ab245e8ca \
--hash=sha512:db5661b77b90eaecf04d80cebc1023ec7930bd639aed075d24291f897784d040ccc3fc5f9db310a3886f1661a0d163aaf42a8c5549b566027e890df42bb1bc0d
aiohttp==1.1.1 \
--hash=sha512:21954987936b1670af2b1bc376d9a0cf2d4c94f967938d5710c6e99037bc4ef43b56b0b0740243e4909d78b0b2a96c9f645937a7d474fc2425f5c05d53655a4d \
--hash=sha512:ffe30c7d0417169df890615dfed123f99dec6627c324a4ac2ee27059c0aeee532b79543e4c06a084d6d86bde18c45c463ab8a994007b4866b77c9716c3d7d77c \
--hash=sha512:6803bf65657742e31da68bb5a50ee1a05204b9cc594e0f1cfcc56f2de902462327eb67cc9042b23e20a454a1f37e4f32d9dcb4b47639018098cd9cb26e0cca8e \
--hash=sha512:389d2e10b0f224ee52f6ff0c8080a909b33c3aad0d6ae1b87a7d717e6daf8376486e6df748e31c99966f736ad697b3e7460d2f1aa7a5b04c66d30ee1c98d7c48 \
--hash=sha512:d7fd98bbbef1f12005a2ead2f62fa26db0d7133276199d52d3958da3e35db02fafdf5ccd11bf96fee7adc021967e71dc8833d4eab0ad8de268b47310cdc60b6d \
--hash=sha512:39321b3d4d5f0754f1cc858dc2cbdf45073d88461ad8a21f5f46405e84461c874ba9bd3b0170cce9fd97ab717caf16f78850bb2573d7c55f6b5cbccbd440e9e2 \
--hash=sha512:f9ab0bcbfc4b4f50c70344b21a3741fcd5e842112636fd0c6985472de10cb532bcfd54280ff537ea8189b275d7e29afec813b99dff9ed8adb363ba1803bf03a3 \
--hash=sha512:96a4484d27eb22abe62dadb3177e5d2af28cd42c81dcc388c0f35f5942b9a3136a58f5074967db884dffe1ef518ccfa0714937787e76fee58403fc3907948235 \
--hash=sha512:8aadcc62129c40aa155dca5719a25849900320e7b92a31d9962b50855d3a2b7fb2b12fddbb2084e52cd941d0d19197bfaab4146efa86450c7348e5d0c4a840c9
arrow==0.8.0 \
--hash=sha512:b6c01970d408e1169d042f593859577eef9961a2e7d6e0d5d01ddbdc001f806ca191cf152bd2d4060a877aeabee6754f06c3b91fbca53ee0a135a9355d08b347
async-timeout==1.1.0 \
Expand Down Expand Up @@ -79,3 +79,13 @@ taskcluster==0.3.4 \
virtualenv==15.0.3 \
--hash=sha512:34486ae905ea83c092418efaf6abae05cdd2d36c32f452ad25775452412c1b6c97de7dccb0f634a3f8a7b1768ed9975b5f16a79fe711ac1cecffd0a46e245583 \
--hash=sha512:f417dbefe8864be9028ab9efd69844b94550dc7f739688b00c32c15ad4f84a2b0d4885564ed0d0e0b43960a328fe81092cebfb8dd0d4b10a804b42122d9c9621
yarl==0.5.3 \
--hash=sha512:6283e6104ca8c399ece4a3bcf0701361c5d4a1b9bd1f175d9ea1a798e387fabe3e71935441acb3a5362fce82defa7e1eabd370121b6ab69797a1a2a93b4a10e1 \
--hash=sha512:d00560013883df51551384c9e957e0cfa4a3b2bef726ff19ddd07d48d25c6d9d419c999cfcf834c45b191708983eea4401a231d62bbddadae98757ba6a4f32ce \
--hash=sha512:5d6f8fddb0a78cc610292d06c6bf1a805f68f86182efc4cca28d62c708dae3360c93d28764d3f2dc47c7be5089a169920eca0e71cb757c16fdf3ff7f017a277d \
--hash=sha512:a3648ab98dfe9f87fb8f07f89b0932bd4caa308f2da843f02f20d826dca7932d5f0d9449ab3aa643f4ee01d5e380ab5347014df5769ee5b81b697771d9119efc \
--hash=sha512:077447b58925d6b3f4703e72615b4845a60844afa0f2abbba675879e8f1cf3a2c7aa103b73c2452e3a7696937c54b8574b685c9bc88ff8ed07f1810e6b3a3f16 \
--hash=sha512:68242d020a07179e5a2245b8cf1a0df30f8aa61b0094ea52bc1fb7ee27d48ebe98247f3b391249cf0b52bd5960ed714a71c016c347869541ef71441494592ad8 \
--hash=sha512:7298a78b61f8d5d1032445db0c5c88785bf8c6e80df7202dc8edd48b8188df83dbea3311be7fad9547f8211751f96deb945f7614c43af24f01c6fc8acefcd3df \
--hash=sha512:658196a3ebd1e79ae6e76354b6cb43f460736a1fa8fe548f3e22666a7c1dcda557f28f22996d640f316ed0f050815889381be97eb59b4ccf305e68c2b40a335d \
--hash=sha512:f5bbee7677a86fd808c66df12f5e9ac6e82f6b383154eefb101bf05c540355bf6fbbdd3a42d61c90d80c56854c2a3496d6c05d312c47cd7ddbd08c171f48c5fc
36 changes: 23 additions & 13 deletions requirements-test-prod.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ PyYAML==3.12 \
--hash=sha512:13733054619053893f4a8d75c1da020a87e1f697b007ab182be06b5b941b49c4cb3dc6f9ff131be6bc10fc727ad7334fa5401346f3a77140aed0f86280532fce \
--hash=sha512:5ff411ddbbf733ad52334015a04eb061998803ff94ad474ea2d534a713aa302cdfadde908ff2bb1dbd4f13e1a1fb99786f8dd1be1e061fcb6a7c0f471e41591f \
--hash=sha512:4ae6c5843688f45751ddb14a8b6f16f58b1f8a4805be430afa4035857b1826be95a8422395d64ac88282f9edd57f35fee5d1b6a4dab9093d47491d300d2079f3
aiohttp==1.0.5 \
--hash=sha512:520bbc3283de9f215ff57e3ab2e0f9255caef3bff65dd47d6ef846845732ec0ddb32488897241a0a03839e38569cb5a083300318df0e431677eeea1676c981d0 \
--hash=sha512:fd67c2a32b355e38aec5447af1decfa3efe91511a3d196c29c0f2b80fe208f11a89502e724468c3f23eb081875ced3044f1712db5f46cebe2abdc36bb4f88207 \
--hash=sha512:c18665e6ac0f71e8fcac35a66937f0226c8e4af4ddca2b15a27a77da3cf7172d3fe3f08ba202ca934aae27ea7676b8f9a0c2ee52acbb9d2f3bf922eafd89aab0 \
--hash=sha512:196a2f2604741b457a37529598c334aa6544923f979c4cf7394325a41e193953b926371332c06f30969cdc62ba9b19009f4bae8cb4bdcaa20f95410115a814af \
--hash=sha512:975f16c5c2eb3821ccbbd465acd6113b18c64a50f879143760e8fc457eb40548c29bccc215b55348c78e9de25c625a4aa94698e034fea3020a7d603ab8cf8264 \
--hash=sha512:d034ac08cc5c68753915df4dbe3e894a9fc09d423aff51c43d44eaafb0d12be84f8c21438ae29f6b828db9b586b952547becbd79d2209b4fbfd66d8dac4dad33 \
--hash=sha512:c0e1c4c65d2e3d4fce0c072e9876be0a39fee2e5ea727d5fdc9de361356f0744a5fe0a6b02e99358d2322144fa5dffbba1d966e24c4622070ffaf5f389f42198 \
--hash=sha512:a15ae9cd0d9409f6005b044249448fb079734517b1f2c93b898693657c2f2af389b924b30b36b4c03f91a599b2e85ffffa1e9ae458f6809f0a169e2ab245e8ca \
--hash=sha512:db5661b77b90eaecf04d80cebc1023ec7930bd639aed075d24291f897784d040ccc3fc5f9db310a3886f1661a0d163aaf42a8c5549b566027e890df42bb1bc0d
aiohttp==1.1.1 \
--hash=sha512:21954987936b1670af2b1bc376d9a0cf2d4c94f967938d5710c6e99037bc4ef43b56b0b0740243e4909d78b0b2a96c9f645937a7d474fc2425f5c05d53655a4d \
--hash=sha512:ffe30c7d0417169df890615dfed123f99dec6627c324a4ac2ee27059c0aeee532b79543e4c06a084d6d86bde18c45c463ab8a994007b4866b77c9716c3d7d77c \
--hash=sha512:6803bf65657742e31da68bb5a50ee1a05204b9cc594e0f1cfcc56f2de902462327eb67cc9042b23e20a454a1f37e4f32d9dcb4b47639018098cd9cb26e0cca8e \
--hash=sha512:389d2e10b0f224ee52f6ff0c8080a909b33c3aad0d6ae1b87a7d717e6daf8376486e6df748e31c99966f736ad697b3e7460d2f1aa7a5b04c66d30ee1c98d7c48 \
--hash=sha512:d7fd98bbbef1f12005a2ead2f62fa26db0d7133276199d52d3958da3e35db02fafdf5ccd11bf96fee7adc021967e71dc8833d4eab0ad8de268b47310cdc60b6d \
--hash=sha512:39321b3d4d5f0754f1cc858dc2cbdf45073d88461ad8a21f5f46405e84461c874ba9bd3b0170cce9fd97ab717caf16f78850bb2573d7c55f6b5cbccbd440e9e2 \
--hash=sha512:f9ab0bcbfc4b4f50c70344b21a3741fcd5e842112636fd0c6985472de10cb532bcfd54280ff537ea8189b275d7e29afec813b99dff9ed8adb363ba1803bf03a3 \
--hash=sha512:96a4484d27eb22abe62dadb3177e5d2af28cd42c81dcc388c0f35f5942b9a3136a58f5074967db884dffe1ef518ccfa0714937787e76fee58403fc3907948235 \
--hash=sha512:cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e
arrow==0.8.0 \
--hash=sha512:b6c01970d408e1169d042f593859577eef9961a2e7d6e0d5d01ddbdc001f806ca191cf152bd2d4060a877aeabee6754f06c3b91fbca53ee0a135a9355d08b347
async-timeout==1.1.0 \
Expand Down Expand Up @@ -122,9 +122,9 @@ pytest-asyncio==0.5.0 \
pytest-cov==2.4.0 \
--hash=sha512:dc11d4098c98baed9c0a6a97bce9cf353c4af0e4f2e755e25826efcde079f8f67305ebc14041705b339d7b87dbfa11b03ad351e78b69768e959e6c9bba3c275b \
--hash=sha512:288e621b3ef47bb3cefa64ce082da0471ef39b0d5fc8f59ad58487139a58ae5705b57c0cd8e48f41ea7230b923f6282f03577030bf973315cb544a4fe0a3ca60
pytest-mock==1.3.0 \
--hash=sha512:5e871a7631cfa56e4264254545f9150c4ea30043d6699405bf003c37357933bec97efd887e768a45995e42af71ce046df287e9ac321ac712e38ae81755ca51e2 \
--hash=sha512:5a457d16f1b6fe2e2f92d09ad129ffc3e12263e31d02a63b44dbbf50a367cfde5076a425e81f9f09e340a688970abf3a9839ab7038953ba7b438c5f7f09a3c2d
pytest-mock==1.4.0 \
--hash=sha512:1663cb3176cf08772230509d96f210081715ba9a4bb9310ffadf3a1e6ce22071d881524d2e44a8b3a9530ac5f95911d396e001ff808b4b599f6ef0bbf9baf99d \
--hash=sha512:351813d18f59528de0e92ec498e97d31998581b7ba3c9d02fcb8ca4804ee825a4fce760a041b64f56f259fa6f36dd4b84624e635da5b9b8e0354ff0760cede53
python-dateutil==2.5.3 \
--hash=sha512:413b935321f0a65fd8e8ba49990acd5bed60b9bcd614837a26c1cf52ecbf268543a97791dfa7b91ebf183866a8de7be302ca7d18d10352e897994f60bce5df62 \
--hash=sha512:d8e28dad57ea85663962f4518faea0eb551248ce5dbb0fb1071aa16d3cfa11e303beb4e6f3477ed02cceb42c328c324fa7183bf70beedbe14e579f0b3e8aa3b9 \
Expand All @@ -148,3 +148,13 @@ tox==2.4.1 \
virtualenv==15.0.3 \
--hash=sha512:34486ae905ea83c092418efaf6abae05cdd2d36c32f452ad25775452412c1b6c97de7dccb0f634a3f8a7b1768ed9975b5f16a79fe711ac1cecffd0a46e245583 \
--hash=sha512:f417dbefe8864be9028ab9efd69844b94550dc7f739688b00c32c15ad4f84a2b0d4885564ed0d0e0b43960a328fe81092cebfb8dd0d4b10a804b42122d9c9621
yarl==0.5.3 \
--hash=sha512:6283e6104ca8c399ece4a3bcf0701361c5d4a1b9bd1f175d9ea1a798e387fabe3e71935441acb3a5362fce82defa7e1eabd370121b6ab69797a1a2a93b4a10e1 \
--hash=sha512:d00560013883df51551384c9e957e0cfa4a3b2bef726ff19ddd07d48d25c6d9d419c999cfcf834c45b191708983eea4401a231d62bbddadae98757ba6a4f32ce \
--hash=sha512:5d6f8fddb0a78cc610292d06c6bf1a805f68f86182efc4cca28d62c708dae3360c93d28764d3f2dc47c7be5089a169920eca0e71cb757c16fdf3ff7f017a277d \
--hash=sha512:a3648ab98dfe9f87fb8f07f89b0932bd4caa308f2da843f02f20d826dca7932d5f0d9449ab3aa643f4ee01d5e380ab5347014df5769ee5b81b697771d9119efc \
--hash=sha512:077447b58925d6b3f4703e72615b4845a60844afa0f2abbba675879e8f1cf3a2c7aa103b73c2452e3a7696937c54b8574b685c9bc88ff8ed07f1810e6b3a3f16 \
--hash=sha512:68242d020a07179e5a2245b8cf1a0df30f8aa61b0094ea52bc1fb7ee27d48ebe98247f3b391249cf0b52bd5960ed714a71c016c347869541ef71441494592ad8 \
--hash=sha512:7298a78b61f8d5d1032445db0c5c88785bf8c6e80df7202dc8edd48b8188df83dbea3311be7fad9547f8211751f96deb945f7614c43af24f01c6fc8acefcd3df \
--hash=sha512:658196a3ebd1e79ae6e76354b6cb43f460736a1fa8fe548f3e22666a7c1dcda557f28f22996d640f316ed0f050815889381be97eb59b4ccf305e68c2b40a335d \
--hash=sha512:f5bbee7677a86fd808c66df12f5e9ac6e82f6b383154eefb101bf05c540355bf6fbbdd3a42d61c90d80c56854c2a3496d6c05d312c47cd7ddbd08c171f48c5fc
2 changes: 2 additions & 0 deletions scriptworker.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ verbose: true
sign_chain_of_trust: false
verify_chain_of_trust: false
verify_cot_signature: false
# Chain of Trust job type, e.g. signing
cot_job_type: signing


#-----------------------------------------------------------------------------------------------
Expand Down
92 changes: 22 additions & 70 deletions scriptworker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
scriptworker.exceptions and scriptworker.constants, or other standalone
modules, to avoid circular imports.
"""
import json
import jsonschema
import os
import re
from urllib.parse import urlparse, unquote

from scriptworker.constants import DEFAULT_CONFIG, STATUSES
from scriptworker.constants import STATUSES
from scriptworker.exceptions import ScriptWorkerTaskException
from scriptworker.utils import load_json, match_url_regex


def get_task(config):
Expand All @@ -27,16 +25,10 @@ def get_task(config):
Raises:
ScriptWorkerTaskException: on error.
"""
try:
path = os.path.join(config['work_dir'], "task.json")
with open(path, "r") as fh:
contents = json.load(fh)
return contents
except (OSError, ValueError) as exc:
raise ScriptWorkerTaskException(
"Can't read task from {}!\n{}".format(path, str(exc)),
exit_code=STATUSES['internal-error']
)
path = os.path.join(config['work_dir'], "task.json")
message = "Can't read task from {}!\n%(exc)s".format(path)
contents = load_json(path, is_path=True, message=message)
return contents


def validate_json_schema(data, schema, name="task"):
Expand All @@ -62,27 +54,16 @@ def validate_json_schema(data, schema, name="task"):
)


def validate_artifact_url(config, url):
def validate_artifact_url(valid_artifact_rules, valid_artifact_task_ids, url):
"""Ensure a URL fits in given scheme, netloc, and path restrictions.

If `valid_artifact_schemes`, `valid_artifact_netlocs`, and/or
`valid_artifact_path_regexes` are defined in `config` but are `None`,
skip that check.

If any are missing from `config`, fall back to the values in
`DEFAULT_CONFIG`.

If `valid_artifact_path_regexes` is not None, the url path should
match one. Each regex should define a `filepath`, which is what we'll
return.

Otherwise, if we pass all checks, return the unmodified path.

If we fail any checks, raise a ScriptWorkerTaskException with
`malformed-payload`.

Args:
config (dict): the running config.
valid_artifact_rules (tuple): the tests to run, with `schemas`, `netlocs`,
and `path_regexes`.
valid_artifact_task_ids (list): the list of valid task IDs to download from.
url (str): the url of the artifact.

Returns:
Expand All @@ -91,50 +72,21 @@ def validate_artifact_url(config, url):
Raises:
ScriptWorkerTaskException: on failure to validate.
"""
messages = []
validate_config = {}
for key in (
'valid_artifact_schemes', 'valid_artifact_netlocs',
'valid_artifact_path_regexes', 'valid_artifact_task_ids',
):
if key in config:
validate_config[key] = config[key]
else:
validate_config[key] = DEFAULT_CONFIG[key]
parts = urlparse(url)
path = unquote(parts.path)
return_value = path
# scheme whitelisted?
if validate_config['valid_artifact_schemes'] is not None and \
parts.scheme not in validate_config['valid_artifact_schemes']:
messages.append('Invalid scheme: {}!'.format(parts.scheme))
# netloc whitelisted?
if validate_config['valid_artifact_netlocs'] is not None and \
parts.netloc not in validate_config['valid_artifact_netlocs']:
messages.append('Invalid netloc: {}!'.format(parts.netloc))
# check the paths
for regex in validate_config.get('valid_artifact_path_regexes') or []:
m = re.search(regex, path)
if m is None:
continue
path_info = m.groupdict()

def callback(match):
path_info = match.groupdict()
# make sure we're pointing at a valid task ID
if 'taskId' in path_info and \
path_info['taskId'] not in validate_config['valid_artifact_task_ids']:
messages.append('Invalid taskId: {}!'.format(path_info['taskId']))
break
path_info['taskId'] not in valid_artifact_task_ids:
return
if 'filepath' not in path_info:
messages.append('Invalid regex {}!'.format(regex))
break
return_value = path_info['filepath']
break
else:
if validate_config.get('valid_artifact_path_regexes'):
messages.append('Invalid path: {}!'.format(path))

if messages:
return
return path_info['filepath']

filepath = match_url_regex(valid_artifact_rules, url, callback)
if filepath is None:
raise ScriptWorkerTaskException(
"Can't validate url {}\n{}".format(url, messages),
"Can't validate url {}".format(url),
exit_code=STATUSES['malformed-payload']
)
return return_value.lstrip('/')
return filepath.lstrip('/')
11 changes: 4 additions & 7 deletions scriptworker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import argparse
from copy import deepcopy
from frozendict import frozendict
import json
import logging
import os
import re
Expand All @@ -19,6 +18,7 @@
from scriptworker.constants import DEFAULT_CONFIG
from scriptworker.context import Context
from scriptworker.log import update_logging_config
from scriptworker.utils import load_json

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -64,12 +64,9 @@ def read_worker_creds(key="credentials"):
for path in CREDS_FILES:
if not os.path.exists(path):
continue
with open(path, "r") as fh:
try:
contents = json.load(fh)
return contents[key]
except (json.decoder.JSONDecodeError, KeyError):
pass
contents = load_json(path, is_path=True, exception=None)
if contents.get(key):
return contents[key]
else:
if key == "credentials" and os.environ.get("TASKCLUSTER_ACCESS_TOKEN") and \
os.environ.get("TASKCLUSTER_CLIENT_ID"):
Expand Down
Loading