Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 src/ocspdash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
__title__ = 'OCSPdash'
# keep the __description__ synchronized with the package docstring
__description__ = "A dashboard for the status of the top certificate authorities' OCSP responders."

__url__ = 'https://github.com/scolby33/OCSPdash'

__author__ = 'Scott Colby'
Expand Down
22 changes: 18 additions & 4 deletions src/ocspdash/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ def web(host, port, flask_debug, verbose):
logging.basicConfig(level=(logging.DEBUG if verbose else logging.INFO))

from ocspdash.web import create_application

app = create_application()
app.run(host=host, port=port, debug=flask_debug)


@main.command()
@click.option('-n', '--buckets', default=2, type=int, help='Number of top authorities')
@click.option('--connection', help=f'SQLAlchemy connection. Defaults to {OCSPDASH_DEFAULT_CONNECTION}')
@click.option(
'--connection',
help=f'SQLAlchemy connection. Defaults to {OCSPDASH_DEFAULT_CONNECTION}',
)
@click.option('-v', '--verbose', is_flag=True, help='Verbose output')
def update(buckets, connection, verbose):
"""Update the local database."""
Expand All @@ -43,7 +47,10 @@ def update(buckets, connection, verbose):


@main.command()
@click.option('--connection', help=f'SQLAlchemy connection. Defaults to {OCSPDASH_DEFAULT_CONNECTION}')
@click.option(
'--connection',
help=f'SQLAlchemy connection. Defaults to {OCSPDASH_DEFAULT_CONNECTION}',
)
@click.option('-y', '--yes', is_flag=True)
def nuke(connection, yes):
"""Nuke the database."""
Expand All @@ -53,15 +60,22 @@ def nuke(connection, yes):


@main.command()
@click.option('--connection', help=f'SQLAlchemy connection. Defaults to {OCSPDASH_DEFAULT_CONNECTION}')
@click.option(
'--connection',
help=f'SQLAlchemy connection. Defaults to {OCSPDASH_DEFAULT_CONNECTION}',
)
@click.argument('location_name')
def new_location(connection, location_name):
"""Register a new location."""
m = Manager.from_args(connection=connection)

invite_id, invite_validator = m.create_location(location_name)

click.echo(base64.urlsafe_b64encode(b''.join((invite_id, invite_validator))).decode("utf-8"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this line is too long (and has too many inner calls) so you should change it to have more temporary variables

click.echo(
base64.urlsafe_b64encode(b''.join((invite_id, invite_validator))).decode(
'utf-8'
)
)


if __name__ == '__main__':
Expand Down
16 changes: 12 additions & 4 deletions src/ocspdash/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,27 @@

#: The directory in which data for OCSP Dashboard is stored. Can be set from the environment variable
#: ``OCSPDASH_DIRECTORY`` or defaults to ``~/.ocspdash``
OCSPDASH_DIRECTORY = os.environ.get('OCSPDASH_DIRECTORY', os.path.join(os.path.expanduser('~'), '.ocspdash'))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

should save default OCSPdash location as a variable as well

OCSPDASH_DIRECTORY = os.environ.get(
'OCSPDASH_DIRECTORY', os.path.join(os.path.expanduser('~'), '.ocspdash')
)

if not os.path.exists(OCSPDASH_DIRECTORY):
os.makedirs(OCSPDASH_DIRECTORY)

OCSPDASH_DEFAULT_CONNECTION = 'sqlite:///' + os.path.join(OCSPDASH_DIRECTORY, 'ocspdash.db')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't like what it did here

OCSPDASH_DEFAULT_CONNECTION = 'sqlite:///' + os.path.join(
OCSPDASH_DIRECTORY, 'ocspdash.db'
)
OCSPDASH_CONNECTION = os.environ.get('OCSPDASH_CONNECTION', OCSPDASH_DEFAULT_CONNECTION)

#: The rate limit for connecting to Censys. Can be set from the environmental variable ``OCSPDASH_RATE`` or defaults
# to ``0.2``.
CENSYS_RATE_LIMIT = float(os.environ.get('OCSPDASH_RATE', 0.2)) # max requests per second

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

too bad os.environ.get doesn't work like the one from flask.request.args.get

CENSYS_RATE_LIMIT = float(
os.environ.get('OCSPDASH_RATE', 0.2)
) # max requests per second

OCSPDASH_USER_AGENT_IDENTIFIER = f'OCSPdash/{VERSION}'
OCSPDASH_USER_AGENT = ' '.join([requests.utils.default_user_agent(), OCSPDASH_USER_AGENT_IDENTIFIER])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why do you write it with a join on a space

OCSPDASH_USER_AGENT = ' '.join(
[requests.utils.default_user_agent(), OCSPDASH_USER_AGENT_IDENTIFIER]
)

OCSP_JWT_ALGORITHM = os.environ.get('OCSP_JWT_ALGORITHM', 'ES512')
4 changes: 1 addition & 3 deletions src/ocspdash/custom_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
import sqlalchemy.dialects.postgresql
from sqlalchemy.types import BINARY, TypeDecorator

__all__ = [
'UUID',
]
__all__ = ['UUID']


class UUID(TypeDecorator):
Expand Down
Loading