Merge ~alexmurray/ubuntu-security-tools:restore-uaudit-command into ubuntu-security-tools:master

Proposed by Alex Murray
Status: Merged
Merged at revision: 0afde0d7d8a7506f31d853c89e39566e9bf30ba9
Proposed branch: ~alexmurray/ubuntu-security-tools:restore-uaudit-command
Merge into: ubuntu-security-tools:master
Diff against target: 29 lines (+11/-1)
2 files modified
audits/README.md (+1/-1)
audits/uaudit (+10/-0)
Reviewer Review Type Date Requested Status
Spyros Seimenis Approve
Ubuntu Security Team Pending
Review via email: mp+464281@code.launchpad.net

Description of the change

audits: add uaudit wrapper script to restore old behaviour

This allows one to run uaudit again without having to install it first
via pipx etc

Signed-off-by: Alex Murray <email address hidden>

To post a comment you must log in.
Revision history for this message
Spyros Seimenis (sespiros) wrote :

The reasoning behind the uaudit -> uaudit.py change was making setting up standalone scanner vms/containers that run uaudit more straight forward and require less custom steps. The change towards that was introduced in this branch:

https://code.launchpad.net/~sespiros/ubuntu-security-tools/+git/ubuntu-security-tools/+ref/add-python-packaging

The pipx method was simply a workaround to make use of the above while at the same time making it easy to run uaudit locally as usual.

This alternative wrapper script also LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/audits/README.md b/audits/README.md
2index 5f7a908..186de82 100644
3--- a/audits/README.md
4+++ b/audits/README.md
5@@ -23,7 +23,7 @@ active development.
6
7 ## Using `uaudit`
8
9-1. Make sure `audits-*`, `check-source-package` and `shellcheck.sh` are in your `PATH`. It is easiest to symlink them into `~/bin`.
10+1. Make sure `uaudit`, `audits-*`, `check-source-package` and `shellcheck.sh` are in your `PATH`. It is easiest to symlink them into `~/bin`.
11 - Or on latest Ubuntu, you can install uaudit with pipx in editable mode by navigating to ubuntu-security-tools and doing `pipx install -e .`
12 2. Read the `uaudit` help: `uaudit --help`
13 3. Create a place for your notes and builds (optional):
14diff --git a/audits/uaudit b/audits/uaudit
15new file mode 100755
16index 0000000..f2ba9d3
17--- /dev/null
18+++ b/audits/uaudit
19@@ -0,0 +1,10 @@
20+#!/bin/bash
21+
22+SOURCE=${BASH_SOURCE[0]}
23+while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
24+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
25+ SOURCE=$(readlink "$SOURCE")
26+ [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
27+done
28+DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && cd .. && pwd )
29+PYTHONPATH=$DIR python3 -m audits.uaudit "$@"

Subscribers

People subscribed via source and target branches