thinkst / canarytokens

Canarytokens helps track activity and actions on your network.
http://canarytokens.org
Other
1.76k stars 258 forks source link

Add lambda and dynamodb infra for exposed key checker #613

Closed gjcthinkst closed 1 week ago

gjcthinkst commented 1 week ago

Proposed changes

Add the infrastructure required to process AWS support emails and post newly exposed AWS API key tokens to the corresponding tokens server.

Types of changes

What types of changes does your code introduce to this repository?

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Testing

Manual tests

I applied the terraform config to my dev account in multiple different configurations to test the processing and error handling. tokens_post_url_override was set to a webhook.site URL to check POSTs.

Unit tests

I ran the lambda-specific unit tests:

================================================================================================================================================== test session starts ===================================================================================================================================================
platform darwin -- Python 3.10.15, pytest-8.3.3, pluggy-1.5.0 -- /Users/gerrie/.cache/uv/archive-v0/XpoMcqSY_smJz1hQxGiHO/bin/python
cachedir: .pytest_cache
rootdir: /Users/gerrie/Work/canarytokens
configfile: pyproject.toml
collected 4 items

tests/test_lambda.py::test_parsing PASSED                                                                                                                                                                                                                                                                          [ 25%]
tests/test_lambda.py::test_ignore_keywords PASSED                                                                                                                                                                                                                                                                  [ 50%]
tests/test_lambda.py::test_parse_failure PASSED                                                                                                                                                                                                                                                                    [ 75%]
tests/test_lambda.py::test_url_parsing PASSED                                                                                                                                                                                                                                                                      [100%]

==================================================================================================================================================== warnings summary ====================================================================================================================================================
../../../.cache/uv/archive-v0/XpoMcqSY_smJz1hQxGiHO/lib/python3.10/site-packages/_pytest/config/__init__.py:1441
  /Users/gerrie/.cache/uv/archive-v0/XpoMcqSY_smJz1hQxGiHO/lib/python3.10/site-packages/_pytest/config/__init__.py:1441: PytestConfigWarning: Unknown config option: asyncio_mode

    self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
============================================================================================================================================== 4 passed, 1 warning in 0.08s ==============================================================================================================================================