-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
nist-feed: init at 0-unstable-2024-01-20 #284812
base: master
Are you sure you want to change the base?
Changes from all commits
e7a63ee
2881fc2
d64f4c0
1bf4758
401d32c
21e4e81
978acd8
01ef3c2
cbd62b5
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 | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||
{ config, lib, pkgs, ... }: | ||||||
|
||||||
with lib; | ||||||
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.
Suggested change
Bad practice that's now discouraged in nixpkgs. |
||||||
|
||||||
let | ||||||
cfg = config.programs.nist-feed; | ||||||
in | ||||||
{ | ||||||
options = { | ||||||
programs.nist-feed = { | ||||||
octodi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
enable = mkEnableOption (mdDoc "NIST Feed, which notifies you about the newest published CVEs"); | ||||||
package = mkPackageOption pkgs "nist-feed" { }; | ||||||
extraArgs = mkOption { | ||||||
type = with types; listOf str; | ||||||
default = [ "-l" "-s" "CRITICAL" ]; | ||||||
description = mdDoc '' | ||||||
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.
Suggested change
|
||||||
Arguments to provide to NIST-Feed, see a full list at | ||||||
<https://github.com/D3vil0p3r/NIST-Feed/blob/main/README.md#nist-feed> | ||||||
''; | ||||||
}; | ||||||
|
||||||
onCalendar = mkOption { | ||||||
type = types.str; | ||||||
default = "*:0/30"; | ||||||
description = mdDoc '' | ||||||
How often NIST-Feed executes. | ||||||
octodi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
''; | ||||||
}; | ||||||
}; | ||||||
}; | ||||||
|
||||||
config = mkIf cfg.enable { | ||||||
environment.systemPackages = [ cfg.package ]; | ||||||
octodi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
systemd.user.services.nist-feed = { | ||||||
wantedBy = [ "default.target" ]; | ||||||
description = "A notification daemon for CVEs"; | ||||||
serviceConfig = { | ||||||
Type = "oneshot"; | ||||||
ExecStart = "${cfg.package}/bin/nist-feed ${escapeShellArgs cfg.extraArgs}"; | ||||||
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.
Suggested change
|
||||||
}; | ||||||
}; | ||||||
|
||||||
systemd.user.timers.nist-feed = { | ||||||
wantedBy = [ "default.target" ]; | ||||||
timerConfig = { | ||||||
Unit = "nist-feed.service"; | ||||||
OnCalendar = cfg.onCalendar; | ||||||
Persistent = "true"; | ||||||
}; | ||||||
}; | ||||||
}; | ||||||
|
||||||
meta.maintainers = with maintainers; [octodi]; | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- a/nist-feed 2024-01-28 19:03:44.721621784 +0530 | ||
+++ b/nist-feed 2024-01-29 18:58:25.981732803 +0530 | ||
@@ -1,7 +1,5 @@ | ||
#!/bin/sh | ||
|
||
-pkill -f "/usr/bin/gjs /usr/share/gnome-shell/org.gnome.Shell.Notifications" | ||
- | ||
############################################################ | ||
# Colors # | ||
############################################################ | ||
@@ -67,7 +65,7 @@ | ||
echo "-i Filter by integrity metric (NONE='I:N', LOW='I:L' or HIGH='I:H')." | ||
echo "-l Retrieve the latest CVE according to the filters." | ||
echo "-m Filter by the specified CVSSv3 metric codes. It is used mainly for managing all filters selected by the user when the notification popup must be created." | ||
- echo "-n Enable desktop notification for the latest CVE according the applied filters by crontab." | ||
+ echo "-n Notification option has been removed for nix, to enable notifications use programs.nist-feed.enable = true; " | ||
echo "-P Filter by privileges required metric (NONE='PR:N', LOW='PR:L' or HIGH='PR:H')." | ||
echo "-r Specify the maximum number of results that are returned based on the request parameters. The default value is 20. For network considerations, maximum allowable limit is 2,000." | ||
echo "-S Filter by scope metric (UNCHANGED='S:U' or CHANGED='S:C')." | ||
@@ -237,7 +235,6 @@ | ||
|
||
if [ "$end" ]; then | ||
echo "Disabling NIST NVD feed popup notification..." | ||
- crontab -l | sed '/nist-feed/d' | crontab | ||
rm -rf $last_cve_file | ||
rm -rf $cve_json_file | ||
exit 0 | ||
@@ -336,27 +333,13 @@ | ||
fi | ||
fi | ||
|
||
-if [[ "$id" != "$LAST_CVE" ]] || [ $(crontab -l | wc -c) -eq 0 ];then #if the previous CVE is different from the current one, OR the crontab is empty, popup notification | ||
+if [[ "$id" != "$LAST_CVE" ]];then #if the previous CVE is different from the current one, OR the crontab is empty, popup notification | ||
if [[ ! "$notify" ]]; then #LAST_CVE must be set only if the user does not set the notification parameters, otherwise when crontab will call the 1st time nist-feed, $id is already = to $LAST_CVE | ||
echo "$id" > $last_cve_file | ||
#Generate the popup notification | ||
killall dunst;notify-send -u normal "$id" "$description\n\n<b>$nvdURL</b>" | ||
fi | ||
|
||
- if [[ "$notify" -eq 1 ]] && [ ! "$severity" ] && [ ! "$metric" ]; then | ||
- crontab -l | sed '/nist-feed/d' | crontab | ||
- (crontab -l 2>/dev/null; echo "*/30 * * * * ( killall dunst ; XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/local/bin/nist-feed -l)") | crontab - | ||
- elif [[ "$notify" -eq 1 ]] && [ "$severity" ] && [ ! "$metric" ]; then | ||
- crontab -l | sed '/nist-feed/d' | crontab | ||
- (crontab -l 2>/dev/null; echo "*/30 * * * * ( killall dunst ; XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/local/bin/nist-feed -l -s $severity)") | crontab - | ||
- elif [[ "$notify" -eq 1 ]] && [ ! "$severity" ] && [ "$metric" ]; then | ||
- crontab -l | sed '/nist-feed/d' | crontab | ||
- (crontab -l 2>/dev/null; echo "*/30 * * * * ( killall dunst ; XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/local/bin/nist-feed -l -m $metric)") | crontab - | ||
- elif [[ "$notify" -eq 1 ]] && [ "$severity" ] && [ "$metric" ]; then | ||
- crontab -l | sed '/nist-feed/d' | crontab | ||
- (crontab -l 2>/dev/null; echo "*/30 * * * * ( killall dunst ; XDG_RUNTIME_DIR=/run/user/$(id -u) /usr/local/bin/nist-feed -l -s $severity -m $metric)") | crontab - | ||
- fi | ||
- | ||
fi | ||
|
||
rm -rf $cve_json_file |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,50 @@ | ||||||||||
{ stdenvNoCC | ||||||||||
, lib | ||||||||||
, fetchFromGitHub | ||||||||||
, makeWrapper | ||||||||||
, bash | ||||||||||
, jq | ||||||||||
, killall | ||||||||||
, libnotify | ||||||||||
, curl | ||||||||||
, busybox | ||||||||||
}: | ||||||||||
|
||||||||||
stdenvNoCC.mkDerivation { | ||||||||||
pname = "nist-feed"; | ||||||||||
version = "0-unstable-2024-01-20"; | ||||||||||
|
||||||||||
src = fetchFromGitHub { | ||||||||||
owner = "D3vil0p3r"; | ||||||||||
repo = "NIST-Feed"; | ||||||||||
rev = "775bd871490b680784a1855cdc1d4958a83a7866"; | ||||||||||
hash = "sha256-OcVf766q7vELYkGOEzQMLS6zH8Nn96ibGP+6kizHN28="; | ||||||||||
}; | ||||||||||
|
||||||||||
patches = [ | ||||||||||
./cron.patch | ||||||||||
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. Maybe the name of this patch could be a bit more descriptive?
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. should definitely have a comment explaining why it's needed and/or why it couldn't be upstreamed |
||||||||||
]; | ||||||||||
|
||||||||||
nativeBuildInputs = [ makeWrapper ]; | ||||||||||
|
||||||||||
postPatch = '' | ||||||||||
substituteInPlace nist-feed \ | ||||||||||
--replace "/usr/local/bin/nist-feed" $out/bin/nist-feed | ||||||||||
''; | ||||||||||
|
||||||||||
installPhase = '' | ||||||||||
runHook preInstall | ||||||||||
install -Dm555 nist-feed $out/bin/nist-feed | ||||||||||
wrapProgram "$out/bin/nist-feed" \ | ||||||||||
--prefix PATH : "$out/bin:${lib.makeBinPath [ jq killall libnotify curl busybox ]}" | ||||||||||
octodi marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
runHook postInstall | ||||||||||
''; | ||||||||||
|
||||||||||
meta = with lib; { | ||||||||||
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.
Suggested change
Tracking issue: #292468 |
||||||||||
description = "Notification daemon for CVEs from the NIST National Vulnerability Database"; | ||||||||||
homepage = "https://github.com/D3vil0p3r/NIST-Feed/"; | ||||||||||
license = licenses.gpl3Plus; | ||||||||||
maintainers = with maintainers; [ octodi ]; | ||||||||||
Comment on lines
+46
to
+47
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.
Suggested change
|
||||||||||
mainProgram = "nist-feed"; | ||||||||||
}; | ||||||||||
} |
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.
There seems to be a conflict left over here