nixpkgs/pkgs/tools/networking/zap/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.5 KiB
Nix
Raw Normal View History

2021-02-08 17:49:25 +01:00
{ lib, stdenv, fetchurl, jre, runtimeShell }:
2016-01-09 05:00:29 +01:00
stdenv.mkDerivation rec {
pname = "zap";
2023-11-16 12:30:26 +01:00
version = "2.14.0";
2021-02-08 17:49:25 +01:00
src = fetchurl {
url = "https://github.com/zaproxy/zaproxy/releases/download/v${version}/ZAP_${version}_Linux.tar.gz";
2023-11-16 12:30:26 +01:00
sha256 = "sha256-IZ1/JbviUkdxOAWrAswSJ5iYyHB0PBquPCsLGIIZGWA=";
2016-01-09 05:00:29 +01:00
};
2021-02-08 17:49:25 +01:00
buildInputs = [ jre ];
2016-01-09 05:00:29 +01:00
2021-02-08 17:49:25 +01:00
# From https://github.com/zaproxy/zaproxy/blob/master/zap/src/main/java/org/parosproxy/paros/Constant.java
2023-01-23 05:52:14 +01:00
version_tag = "20012000";
2016-01-09 05:00:29 +01:00
2021-02-08 17:49:25 +01:00
# Copying config and adding version tag before first use to avoid permission
# issues if zap tries to copy config on it's own.
2016-01-09 05:00:29 +01:00
installPhase = ''
2021-02-08 17:49:25 +01:00
mkdir -p "$out/bin" "$out/share"
cp -pR . "$out/share/${pname}/"
cat >> "$out/bin/${pname}" << EOF
#!${runtimeShell}
export PATH="${lib.makeBinPath [ jre ]}:\$PATH"
export JAVA_HOME='${jre}'
if ! [ -f "\$HOME/.ZAP/config.xml" ];then
2021-02-08 17:49:25 +01:00
mkdir -p "\$HOME/.ZAP"
head -n 2 $out/share/${pname}/xml/config.xml > "\$HOME/.ZAP/config.xml"
echo "<version>${version_tag}</version>" >> "\$HOME/.ZAP/config.xml"
tail -n +3 $out/share/${pname}/xml/config.xml >> "\$HOME/.ZAP/config.xml"
fi
exec "$out/share/${pname}/zap.sh" "\$@"
EOF
chmod u+x "$out/bin/${pname}"
2016-01-09 05:00:29 +01:00
'';
meta = with lib; {
homepage = "https://www.owasp.org/index.php/ZAP";
2016-01-09 05:00:29 +01:00
description = "Java application for web penetration testing";
maintainers = with maintainers; [ mog rafael ];
2016-01-09 05:00:29 +01:00
platforms = platforms.linux;
license = licenses.asl20;
};
}