Merge ubuntu-cve-tracker:usns into ubuntu-cve-tracker:master

Proposed by Mark Esler
Status: Merged
Approved by: Paulo Flabiano Smorigo
Approved revision: 33ebb19d092db53665c67975b47d53d21660c92c
Merged at revision: c9ca284e92c87ee2c7fac1d55f1d8cf2edbdb16d
Proposed branch: ubuntu-cve-tracker:usns
Merge into: ubuntu-cve-tracker:master
Diff against target: 41 lines (+14/-0)
1 file modified
scripts/usngrep (+14/-0)
Reviewer Review Type Date Requested Status
Paulo Flabiano Smorigo Approve
Mark Esler Approve
Review via email: mp+432270@code.launchpad.net

Commit message

usngreps: adds features to print list and count of unique USNs

To post a comment you must log in.
Revision history for this message
Mark Esler (eslerm) wrote :

Paulo approved merge.

review: Approve
Revision history for this message
Paulo Flabiano Smorigo (pfsmorigo) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/scripts/usngrep b/scripts/usngrep
2index 6b5cabf..5411f2b 100755
3--- a/scripts/usngrep
4+++ b/scripts/usngrep
5@@ -12,6 +12,8 @@ parser.add_argument("-t", "--text", action="store_true", help="show text without
6 parser.add_argument("-i", "--ignore-case", action="store_true", help="ignore case for the search")
7 parser.add_argument("-r", "--reverse", action="store_true", help="reverse usn order")
8 parser.add_argument("-c", "--count", action="store_true", help="instead print a count of matching lines for each match")
9+parser.add_argument("-u", "--usns", action="store_true", help="instead print a list of matching USNs")
10+parser.add_argument("-C", "--count-usns", action="store_true", help="instead print a count of matching USNs")
11 parser.add_argument(dest="string", nargs="+", help="text used to search")
12 args = parser.parse_args()
13
14@@ -31,6 +33,7 @@ convert = lambda text: "%010d" % int(text) if text.isdigit() else text.lower()
15 sort_lambda = lambda x: convert(x[0].split("-")[0]) + convert(x[0].split("-")[1])
16 usn_db = sorted(usn_db.items(), key = sort_lambda, reverse = args.reverse)
17 count = 0
18+usns = []
19
20 p = re.compile(r"%s" % " ".join(args.string), re.IGNORECASE if args.ignore_case else 0)
21 for usn in usn_db:
22@@ -41,8 +44,19 @@ for usn in usn_db:
23 if args.count:
24 count += 1
25 continue
26+ if args.usns or args.count_usns:
27+ usns.append(f"USN-{usn[0]}")
28+ continue
29 text = text if args.text else desc.strip()
30 print(f"USN-{usn[0]}\n{text}\n")
31
32 if args.count:
33 print(count)
34+
35+if args.usns or args.count_usns:
36+ usns = sorted(set(usns), reverse = args.reverse)
37+if args.usns:
38+ for u in usns:
39+ print(u)
40+if args.count_usns:
41+ print(len(usns))

Subscribers

People subscribed via source and target branches