-
Notifications
You must be signed in to change notification settings - Fork 688
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
Reject weak keys (SHA-1 signature) in admin gpg-validate script #6928
Changes from all commits
15453e0
a453bf9
941d2e7
a5b9edf
3063ba9
6875fcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,16 @@ | |
DIR = os.path.dirname(os.path.realpath(__file__)) | ||
VENV_DIR = os.path.join(DIR, ".venv3") | ||
|
||
# Space-separated list of apt dependencies | ||
APT_DEPENDENCIES_STR = "python3-virtualenv \ | ||
python3-yaml \ | ||
python3-pip \ | ||
virtualenv \ | ||
libffi-dev \ | ||
libssl-dev \ | ||
libpython3-dev \ | ||
sq-keyring-linter" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (dependencies refactored from line 120) |
||
|
||
def setup_logger(verbose: bool = False) -> None: | ||
"""Configure logging handler""" | ||
|
@@ -95,6 +105,37 @@ def checkenv(args: argparse.Namespace) -> None: | |
sys.exit(1) | ||
|
||
|
||
def is_missing_dependency() -> bool: | ||
""" | ||
Check if there are any missing apt dependencies. | ||
This applies to existing Tails systems where `securedrop-setup` may not have been | ||
run recently. | ||
""" | ||
# apt-cache -q0 policy $dependency1 $dependency2 $dependency3 | grep "Installed: (none)" | ||
apt_query = f"apt-cache -q0 policy {APT_DEPENDENCIES_STR}".split(" ") | ||
grep_command = ["grep", "Installed: (none)"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zenmonkeykstop if the admin workstation has all the right dependencies, If a package name changes (eg sq-keyring-linter gets replaced by sq), this still won't try and install sq-keyring-linter, because the apt-cache policy results wont be If you're not a fan, let me know and we can at least move the check into the branch of envsetup where no existing venv is detected. |
||
|
||
try: | ||
sdlog.info("Checking apt dependencies are installed") | ||
apt_process = subprocess.Popen(apt_query, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | ||
|
||
grep_process = subprocess.Popen( | ||
grep_command, stdin=apt_process.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE | ||
) | ||
|
||
# Wait for the process to complete before checking the returncode | ||
grep_process.communicate() | ||
returncode = grep_process.returncode | ||
|
||
# If the above command returns 0, then one or more packages are not installed. | ||
return returncode == 0 | ||
|
||
except subprocess.CalledProcessError as e: | ||
sdlog.error("Error checking apt dependencies") | ||
sdlog.debug(e.output) | ||
raise | ||
|
||
|
||
def maybe_torify() -> List[str]: | ||
if is_tails(): | ||
return ["torify"] | ||
|
@@ -117,22 +158,16 @@ def install_apt_dependencies(args: argparse.Namespace) -> None: | |
"sudo", | ||
"su", | ||
"-c", | ||
"apt-get update && \ | ||
apt-get -q -o=Dpkg::Use-Pty=0 install -y \ | ||
python3-virtualenv \ | ||
python3-yaml \ | ||
python3-pip \ | ||
virtualenv \ | ||
libffi-dev \ | ||
libssl-dev \ | ||
libpython3-dev", | ||
f"apt-get update && \ | ||
apt-get -q -o=Dpkg::Use-Pty=0 install -y {APT_DEPENDENCIES_STR}", | ||
] | ||
|
||
try: | ||
# Print command results in real-time, to keep Admin apprised | ||
# of progress during long-running command. | ||
for output_line in run_command(apt_command): | ||
print(output_line.decode("utf-8").rstrip()) | ||
|
||
except subprocess.CalledProcessError: | ||
# Tails supports apt persistence, which was used by SecureDrop | ||
# under Tails 2.x. If updates are being applied, don't try to pile | ||
|
@@ -158,11 +193,13 @@ def envsetup(args: argparse.Namespace, virtualenv_dir: str = VENV_DIR) -> None: | |
# clean up old Tails venv on major upgrades | ||
clean_up_old_tails_venv(virtualenv_dir) | ||
|
||
# Check apt dependencies and ensure all are present. | ||
if is_missing_dependency(): | ||
install_apt_dependencies(args) | ||
|
||
# virtualenv doesnt exist? Install dependencies and create | ||
if not os.path.exists(virtualenv_dir): | ||
|
||
install_apt_dependencies(args) | ||
|
||
# Technically you can create a virtualenv from within python | ||
# but pip can only be run over Tor on Tails, and debugging that | ||
# along with instaling a third-party dependency is not worth | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
||
mI0EZOPgWwEEALRtUxob9g8IYRBVGZfsIM79e7OuqCUNnnpcNkNZ4tiKyd8yjjfD | ||
2t4OZ5WAv7VuseDThwGnDoCUJ3ZZXtKTtJITtYvtHsQox3BZoz5wSWRSJDO8npKU | ||
Zv0j7Dy8uqv0n69J402+3Fq9mELyekH9/j29UqLdUTzRQgH+ZkXAH27DABEBAAG0 | ||
O0JBREtFWSAoU2hvdWxkIGZhaWwgc3Eta2V5cmluZy1saW50ZXIpIDxCQURLRVlA | ||
Tk9SRVBMWS5ORVQ+iM4EEwEKADgWIQRA8cF7fngm2rQLFK53hrAA5tCnbgUCZOPg | ||
WwIbAwULCQgHAgYVCgkICwIEFgIDAQIeAQIXgAAKCRB3hrAA5tCnboiIA/oDjkPm | ||
fhg9/2XdylpdB0WhY55vNLweSyQW6tWEgoL4IMl2HJx38WiMsNbqgWfsw/cLHrRW | ||
eQfPJiB4n8jbucSFmutO9nlKT+yN/G1eVrSikz0nZ4OlLtW5Jy2T70LVzo3Lb6fE | ||
Ve9zkVp+AaOxgsxlLj8aEX8E9tdD7EdmMKSJIbiNBGTj4FsBBACt+L8aGNutQfqK | ||
iqqtwncUGBWdXNZgy+2SCmNF6QGwj0m8AlgBjERfbeBcYo3Mw2PIPM1r5UlXFiMy | ||
blF32L7kZGxy5ETYaADHilGoJHCubtpBH4hDRsmt9OKydFSQvE01+CHLmAfiXBzx | ||
KK48B2nVTseLIPhdxOW15GGd9QwLNwARAQABiLYEGAEKACAWIQRA8cF7fngm2rQL | ||
FK53hrAA5tCnbgUCZOPgWwIbDAAKCRB3hrAA5tCnbqQ1A/9JSda8nzav4lgBw8co | ||
dbB0s9AdvGymtlTWLUFdfHRaNYwHInUtXIagDhgJNLaa75xd/WNLvvjPcV3SoaOC | ||
hGVDM/BkMb87VxjeYgHzKdN5MxMrPvITS5Y0EGB0ITvG1MTqHWalhY99pyRqeCRA | ||
2BWLtQSMMPWQxML48db4EtfTQw== | ||
=rpbe | ||
-----END PGP PUBLIC KEY BLOCK----- |
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 returns positive for cases where the supplied fingerprint is truncated by 1 char.