-
Notifications
You must be signed in to change notification settings - Fork 687
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
Adds v2 and v3 source interface urls to metadata endpoint. #5074
Adds v2 and v3 source interface urls to metadata endpoint. #5074
Conversation
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.
👍
This works well. I had one nitpicky naming suggestion and an idea for an extra test.
I went through the test plan with the dev container (having trouble with quay.io at the moment, so couldn't test staging), and everything worked as described.
I got through staging and that worked too, of course. |
… available to Apache
383d257
to
2c57f59
Compare
2c57f59
to
7d74a45
Compare
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.
Testing (worked as expected)
Dev env:
- check out this branch and run
make dev
, then visitlocalhost:8080/metadata
:- the response includes
v2_source_url
andv3_source_url
fields with valuenull
- the response includes
- use
docker ps
anddocker exec -it <PID> bash
to log into the dev container, then create a file/var/lib/securedrop/source_v2_url
containing an invalid onion URL (ie. NOT 16 alphanumeric chars followed by.onion
), with ownership user:root and permissions 777, then check the/metadata
endpoint again- both URL fields are still null
- update the
/var/lib/securedrop/source_v2_url
to contain a valid v2 URL, and check/metadata
again- the
v2_source_url
contains the onion URL specified above
- the
- repeat the two steps above for the
/var/lib/source_v3_url
file and verify that thev3_source_url
behaves as expected.
Staging env:
- check out this branch and run
make build-debs; make staging
, then check the SI url ininstall_files/ansible-base/app-source-ths
and visit its/metadata
endpoint in Tor Browser.- the response includes the v2 and v3 source url fields, with values matching the contents of
install_files/ansible-base/app-source-ths
andinstall_files/ansible-base/app-sourcev3-ths
- the response includes the v2 and v3 source url fields, with values matching the contents of
🦄
@rmol we will need a fresh |
As a note: the metadata endpoint provides JSON data like:
|
Status
Ready for review
Description of Changes
Fixes #4757
Changes proposed in this pull request:
Source Interface information, including versions and submission key fingerprint, is currently available via the
/metadata
endpoint. This PR adds the v2 and v3 source URLs to the endpoint payload, allowing for discovery and monitoring of v3 versions of Source Interfaces.This feature relies on the files
/var/lib/securedrop/source_{v2,v3}_url
, which are created when the install playbook is run from version 1.0.0 onward. In the absence of said files, null values are returned instead.(I decided against adding a postinst task to create said files if the playbook hasn't been run, as if it hasn't been run then v3 hasn't been enabled anyway. Open to debate on this!)
Testing
Dev env:
make dev
, then visitlocalhost:8080/metadata
:v2_source_url
andv3_source_url
fields with valuenull
docker ps
anddocker exec -it <PID> bash
to log into the dev container, then create a file/var/lib/securedrop/source_v2_url
containing an invalid onion URL (ie. NOT 16 alphanumeric chars followed by.onion
), with ownership user:root and permissions 777, then check the/metadata
endpoint again/var/lib/securedrop/source_v2_url
to contain a valid v2 URL, and check/metadata
againv2_source_url
contains the onion URL specified above/var/lib/source_v3_url
file and verify that thev3_source_url
behaves as expected.Staging env:
make build-debs; make staging
, then check the SI url ininstall_files/ansible-base/app-source-ths
and visit its/metadata
endpoint in Tor Browser.install_files/ansible-base/app-source-ths
andinstall_files/ansible-base/app-sourcev3-ths
Deployment
As this change relies on files created by the install playbook, it will only return non-null values on instances where the playbook has been recently run (most likely to enable v3 onion services). For instances where this is not the case, null values will be returned instead.
For new instances, the file dependencies will exist, and so the values will be populated.
Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made changes to
securedrop-admin
:make -C admin test
) pass in the admin development containerIf you made non-trivial code changes: