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

Added CLI args and set inject home directory #43

Merged
merged 13 commits into from
Oct 23, 2018
Merged

Added CLI args and set inject home directory #43

merged 13 commits into from
Oct 23, 2018

Conversation

heartsucker
Copy link
Contributor

Fixes #37
Fixes #38
Fixes #39

Adds an arg parser and makes everything injectable. There is no longer shared global state.

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the PR @heartsucker! just a couple of notes inline

"""
All logging related settings are set up by this function.
"""
if not os.path.exists(LOG_DIR):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the log directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hoping to keep the directory logic all in one place so I pulled that out for now. I can readd it but...

I guess this brings up a broader question which is how strict do we want to be on data directory permissions? Like I think every dir needs to have 00 for the final two bytes, and we should bail otherwise. I know it's Qubes already, but if the directories don't need global rwx, then it shouldn't be set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep the logs dir to prevent clutter

agreed on permissions

description='SecureDrop Journalist GUI')
parser.add_argument(
'-H', '--home', default=DEFAULT_HOME,
help='Home directory for storing files and state')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's avoid the term home for clarity (this comment applies to the entire diff unless we are actually talking about regular ~ home dir), i.e.:

home -> data_dir (or something similar)
"Home directory for storing files and state" -> "Directory for storing securedrop-client files"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then I propose we call it sdc_home or client_home to mimic --gpg-home. I think data_dir isn't totally accurate because to me logs are configs aren't "data" in the /var/lib sense that the term "data dir" often gets used with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm cool with either of these names tbh

run.sh Outdated
Base.metadata.create_all(make_engine("$HOME"))
EOF

exec python -m securedrop_client --home "$HOME"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the developer workflow is:

on first run or any run where we want a temporary database for development:

./run.sh

And developers that want to use a persistent database can do:

python -m securedrop_client --home dirwhereikeepmysvsdatabase/

if you agree, want to add a note to the README.md indicating the above?

@ntoll does this jive with your workflow? 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this wasn't addressed? we should definitely add this information to the readme in the getting started section as it's non obvious unless you read through the dev env

@heartsucker heartsucker force-pushed the cli-args branch 5 times, most recently from e0f8002 to 5ca62a8 Compare October 20, 2018 08:23
@ntoll
Copy link
Contributor

ntoll commented Oct 22, 2018

OK... I think GitHub is working now... on with the PR-mageddon. ;-)

This looks great although make check reports coverage has dropped (see below).

Question: how puritanical do we want to be about test coverage? I tend to think that if we can write a test to exercise some code that isn't already exercised, then we should. Furthermore, if we have problems writing tests for some of the code we've written, then we've probably written it wrong. Finally, if there are places (and, let's be honest, there usually are) where coverage checking isn't really needed we ought to explicitly suppress it so furture-selves / others can see our decision. Having said all that, I'm not that puritanical about this sort of thing, open and flexible to hear what folks think. I guess the important thing is we come to a consensus. :-)

$ make check
... a bunch of stuff ..

----------- coverage: platform linux, python 3.6.6-final-0 -----------
Name                                      Stmts   Miss  Cover   Missing
-----------------------------------------------------------------------
securedrop_client/__main__.py                 2      2     0%   1-3
securedrop_client/app.py                     69      7    90%   81-86, 124, 136-139
securedrop_client/gui/__init__.py             0      0   100%
securedrop_client/gui/main.py                67      0   100%
securedrop_client/gui/widgets.py            258      0   100%
securedrop_client/logic.py                  112      0   100%
securedrop_client/models.py                  72      0   100%
securedrop_client/resources/__init__.py      16      0   100%
securedrop_client/storage.py                105      0   100%
securedrop_client/utils.py                   27      1    96%   15
-----------------------------------------------------------------------
TOTAL                                       728     10    99%

@heartsucker
Copy link
Contributor Author

Ughhhhhhhhhhhh

Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0x00007ffff2720773 in QGuiApplication::font() ()
   from /home/heartsucker/.local/share/virtualenvs/securedrop-client-GExBtLKv/lib/python3.5/site-packages/PyQt5/Qt/lib/libQt5Gui.so.5

@ntoll
Copy link
Contributor

ntoll commented Oct 23, 2018

@heartsucker hugs

Copy link
Contributor

@redshiftzero redshiftzero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for adding these tests ❤️

@redshiftzero redshiftzero merged commit aa2c4bb into master Oct 23, 2018
@redshiftzero redshiftzero deleted the cli-args branch October 23, 2018 22:31
legoktm pushed a commit that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants