another round of refactoring
This commit is contained in:
23 files changed
+1362
-1090
No files matched your search
+15
-65
@@ -9,10 +9,23 @@
|
||||
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
parserChecks = import ./checks/parsers.nix { inherit pkgs; };
|
||||
readmeDocSource = builtins.readFile ../nix/readme-doc.nix;
|
||||
trayModuleSource = builtins.readFile ../modules/proxy-suite/tray.nix;
|
||||
tgWsProxyModuleSource = builtins.readFile ../modules/proxy-suite/tg-ws-proxy.nix;
|
||||
controlModuleSource = builtins.readFile ../modules/proxy-suite/service/control.nix;
|
||||
repoChecks = import ./checks/repo.nix {
|
||||
inherit
|
||||
pkgs
|
||||
rg
|
||||
generatedOptionsDoc
|
||||
generatedReadmeDoc
|
||||
readmeDocSource
|
||||
trayModuleSource
|
||||
tgWsProxyModuleSource
|
||||
controlModuleSource
|
||||
;
|
||||
};
|
||||
evalProxySuite =
|
||||
modules:
|
||||
import "${nixpkgs}/nixos/lib/eval-config.nix" {
|
||||
@@ -2331,69 +2344,6 @@ in
|
||||
grep -F -- '--filter-tcp=443 --dpi-desync=fake,multisplit --hostlist="${zapretHostlistBase}/hostlists/list-example.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude.txt" --hostlist-exclude="${zapretHostlistBase}/hostlists/list-exclude-user.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude.txt" --ipset-exclude="${zapretHostlistBase}/hostlists/ipset-exclude-user.txt" --new' "${zapretHostlistBase}/config"
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
build-outbound-parser =
|
||||
pkgs.runCommand "build-outbound-parser-check" { nativeBuildInputs = [ pkgs.python3 ]; }
|
||||
''
|
||||
export PYTHONDONTWRITEBYTECODE=1
|
||||
export PYTHONPATH=${../scripts}:$PYTHONPATH
|
||||
export BUILD_OUTBOUND_SCRIPT=${../scripts/build-outbound.py}
|
||||
python ${../scripts/test-build-outbound.py}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
fetch-subscription-parser =
|
||||
pkgs.runCommand "fetch-subscription-parser-check" { nativeBuildInputs = [ pkgs.python3 ]; }
|
||||
''
|
||||
export PYTHONDONTWRITEBYTECODE=1
|
||||
export PYTHONPATH=${../scripts}:$PYTHONPATH
|
||||
export FETCH_SUBSCRIPTION_SCRIPT=${../scripts/fetch-subscription.py}
|
||||
python ${../scripts/test-fetch-subscription.py}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
no-secrets = pkgs.runCommand "proxy-suite-no-secrets-check" { } ''
|
||||
repo_root=${../.}
|
||||
if ${rg} --pcre2 -n -I -H -S \
|
||||
-e '-----BEGIN (RSA|DSA|EC|OPENSSH|PGP) PRIVATE KEY-----' \
|
||||
-e 'ghp_[A-Za-z0-9]{36}' \
|
||||
-e 'github_pat_[A-Za-z0-9_]{20,}' \
|
||||
-e 'glpat-[A-Za-z0-9_-]{20,}' \
|
||||
-e 'xox[baprs]-[A-Za-z0-9-]{10,}' \
|
||||
-e 'AKIA[0-9A-Z]{16}' \
|
||||
-e 'AIza[0-9A-Za-z_-]{35}' \
|
||||
-e 'sk-(proj-)?[A-Za-z0-9_-]{20,}' \
|
||||
"$repo_root"; then
|
||||
echo "secret-like content detected in source tree" >&2
|
||||
exit 1
|
||||
fi
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
options-doc = pkgs.runCommand "proxy-suite-options-doc-check" { nativeBuildInputs = [ pkgs.diffutils ]; } ''
|
||||
diff -u ${../docs/options.md} ${generatedOptionsDoc}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
readme-doc = pkgs.runCommand "proxy-suite-readme-doc-check" { nativeBuildInputs = [ pkgs.diffutils ]; } ''
|
||||
diff -u ${../README.md} ${generatedReadmeDoc}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
readme-doc-source = builtins.seq
|
||||
(
|
||||
assert !(pkgs.lib.hasInfix "environment.systemPackages" readmeDocSource);
|
||||
assert !(pkgs.lib.hasInfix "packageByPattern" readmeDocSource);
|
||||
true
|
||||
)
|
||||
(pkgs.writeText "proxy-suite-readme-doc-source-check" "ok");
|
||||
|
||||
package-source = builtins.seq
|
||||
(
|
||||
assert !(pkgs.lib.hasInfix "../../pkgs/proxy-suite-tray.nix" trayModuleSource);
|
||||
assert !(pkgs.lib.hasInfix "../../pkgs/tg-ws-proxy.nix" tgWsProxyModuleSource);
|
||||
assert !(pkgs.lib.hasInfix "../../../pkgs/proxy-ctl.nix" controlModuleSource);
|
||||
true
|
||||
)
|
||||
(pkgs.writeText "proxy-suite-package-source-check" "ok");
|
||||
}
|
||||
// parserChecks
|
||||
// repoChecks
|
||||
@@ -0,0 +1,21 @@
|
||||
{ pkgs }:
|
||||
|
||||
{
|
||||
build-outbound-parser =
|
||||
pkgs.runCommand "build-outbound-parser-check" { nativeBuildInputs = [ pkgs.python3 ]; }
|
||||
''
|
||||
export PYTHONDONTWRITEBYTECODE=1
|
||||
export PYTHONPATH=${../../scripts}:$PYTHONPATH
|
||||
python ${../../scripts/test-build-outbound.py}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
fetch-subscription-parser =
|
||||
pkgs.runCommand "fetch-subscription-parser-check" { nativeBuildInputs = [ pkgs.python3 ]; }
|
||||
''
|
||||
export PYTHONDONTWRITEBYTECODE=1
|
||||
export PYTHONPATH=${../../scripts}:$PYTHONPATH
|
||||
python ${../../scripts/test-fetch-subscription.py}
|
||||
touch "$out"
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
pkgs,
|
||||
rg,
|
||||
generatedOptionsDoc,
|
||||
generatedReadmeDoc,
|
||||
readmeDocSource,
|
||||
trayModuleSource,
|
||||
tgWsProxyModuleSource,
|
||||
controlModuleSource,
|
||||
}:
|
||||
|
||||
{
|
||||
no-secrets = pkgs.runCommand "proxy-suite-no-secrets-check" { } ''
|
||||
repo_root=${../../.}
|
||||
if ${rg} --pcre2 -n -I -H -S \
|
||||
-e '-----BEGIN (RSA|DSA|EC|OPENSSH|PGP) PRIVATE KEY-----' \
|
||||
-e 'ghp_[A-Za-z0-9]{36}' \
|
||||
-e 'github_pat_[A-Za-z0-9_]{20,}' \
|
||||
-e 'glpat-[A-Za-z0-9_-]{20,}' \
|
||||
-e 'xox[baprs]-[A-Za-z0-9-]{10,}' \
|
||||
-e 'AKIA[0-9A-Z]{16}' \
|
||||
-e 'AIza[0-9A-Za-z_-]{35}' \
|
||||
-e 'sk-(proj-)?[A-Za-z0-9_-]{20,}' \
|
||||
"$repo_root"; then
|
||||
echo "secret-like content detected in source tree" >&2
|
||||
exit 1
|
||||
fi
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
options-doc = pkgs.runCommand "proxy-suite-options-doc-check" { nativeBuildInputs = [ pkgs.diffutils ]; } ''
|
||||
diff -u ${../../docs/options.md} ${generatedOptionsDoc}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
readme-doc = pkgs.runCommand "proxy-suite-readme-doc-check" { nativeBuildInputs = [ pkgs.diffutils ]; } ''
|
||||
diff -u ${../../README.md} ${generatedReadmeDoc}
|
||||
touch "$out"
|
||||
'';
|
||||
|
||||
readme-doc-source = builtins.seq
|
||||
(
|
||||
assert !(pkgs.lib.hasInfix "environment.systemPackages" readmeDocSource);
|
||||
assert !(pkgs.lib.hasInfix "packageByPattern" readmeDocSource);
|
||||
true
|
||||
)
|
||||
(pkgs.writeText "proxy-suite-readme-doc-source-check" "ok");
|
||||
|
||||
package-source = builtins.seq
|
||||
(
|
||||
assert !(pkgs.lib.hasInfix "../../pkgs/proxy-suite-tray.nix" trayModuleSource);
|
||||
assert !(pkgs.lib.hasInfix "../../pkgs/tg-ws-proxy.nix" tgWsProxyModuleSource);
|
||||
assert !(pkgs.lib.hasInfix "../../../pkgs/proxy-ctl.nix" controlModuleSource);
|
||||
true
|
||||
)
|
||||
(pkgs.writeText "proxy-suite-package-source-check" "ok");
|
||||
}
|
||||
Reference in new issue
Block a user