nixpkgs/pkgs/tools/security/semgrep/default.nix
2022-09-14 21:52:30 +02:00

86 lines
1.7 KiB
Nix

{ lib
, fetchFromGitHub
, callPackage
, semgrep-core
, buildPythonApplication
, pythonPackages
, pythonRelaxDepsHook
, pytestCheckHook
, git
}:
let
common = callPackage ./common.nix { };
in
buildPythonApplication rec {
pname = "semgrep";
inherit (common) version;
src = "${common.src}/cli";
SEMGREP_CORE_BIN = "${semgrep-core}/bin/semgrep-core";
nativeBuildInputs = [ pythonRelaxDepsHook ];
pythonRelaxDeps = [
"attrs"
"boltons"
"jsonschema"
"typing-extensions"
];
postPatch = ''
# remove git submodule placeholders
rm -r ./src/semgrep/{lang,semgrep_interfaces}
# link submodule dependencies
ln -s ${common.langsSrc}/ ./src/semgrep/lang
ln -s ${common.interfacesSrc}/ ./src/semgrep/semgrep_interfaces
'';
doCheck = true;
checkInputs = [ git pytestCheckHook ] ++ (with pythonPackages; [
pytest-snapshot
pytest-mock
pytest-freezegun
types-freezegun
]);
disabledTests = [
# requires networking
"tests/unit/test_metric_manager.py"
];
preCheck = ''
# tests need a home directory
export HOME="$(mktemp -d)"
# disabledTestPaths doesn't manage to avoid the e2e tests
# remove them from pyproject.toml
# and remove need for pytest-split
substituteInPlace pyproject.toml \
--replace '"tests/e2e",' "" \
--replace 'addopts = "--splitting-algorithm=least_duration"' ""
'';
propagatedBuildInputs = with pythonPackages; [
attrs
boltons
colorama
click
click-option-group
glom
requests
ruamel-yaml
tqdm
packaging
jsonschema
wcmatch
peewee
defusedxml
urllib3
typing-extensions
python-lsp-jsonrpc
];
meta = common.meta // {
description = common.meta.description + " - cli";
};
}