2021-02-19 19:06:45 +00:00
|
|
|
{ lib, stdenv, fetchurl, jre, runtimeShell }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "zap";
|
2021-02-19 19:06:45 +00:00
|
|
|
version = "2.10.0";
|
|
|
|
src = fetchurl {
|
|
|
|
url = "https://github.com/zaproxy/zaproxy/releases/download/v${version}/ZAP_${version}_Linux.tar.gz";
|
|
|
|
sha256 = "1mz9s56pbs62g4pnd1ml8y6jpf9ilisdwwvjv5kn6yxrcdi2zzqh";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-19 19:06:45 +00:00
|
|
|
buildInputs = [ jre ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-19 19:06:45 +00:00
|
|
|
# From https://github.com/zaproxy/zaproxy/blob/master/zap/src/main/java/org/parosproxy/paros/Constant.java
|
|
|
|
version_tag = "2010000";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-19 19:06:45 +00:00
|
|
|
# Copying config and adding version tag before first use to avoid permission
|
|
|
|
# issues if zap tries to copy config on it's own.
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
2021-02-19 19:06:45 +00: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 "~/.ZAP/config.xml" ];then
|
|
|
|
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}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.owasp.org/index.php/ZAP";
|
|
|
|
description = "Java application for web penetration testing";
|
|
|
|
maintainers = with maintainers; [ mog ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
license = licenses.asl20;
|
|
|
|
};
|
|
|
|
}
|