tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
semgrep{,-core}: init at 0.103.0
06kellyjac
3 years ago
6fcf2f68
3567e122
+161
4 changed files
expand all
collapse all
unified
split
pkgs
tools
security
semgrep
common.nix
default.nix
semgrep-core.nix
top-level
all-packages.nix
+55
pkgs/tools/security/semgrep/common.nix
···
1
1
+
{ lib, fetchFromGitHub, fetchzip }:
2
2
+
3
3
+
rec {
4
4
+
version = "0.103.0";
5
5
+
6
6
+
src = fetchFromGitHub {
7
7
+
owner = "returntocorp";
8
8
+
repo = "semgrep";
9
9
+
rev = "v${version}";
10
10
+
sha256 = "sha256-vk6GBgLsXRLAVu60xW4WWWhhi4b1WLceTxh/TeISIUg=";
11
11
+
};
12
12
+
13
13
+
# submodule dependencies
14
14
+
# these are fetched so we:
15
15
+
# 1. don't fetch the many submodules we don't need
16
16
+
# 2. avoid fetchSubmodules since it's prone to impurities
17
17
+
langsSrc = fetchFromGitHub {
18
18
+
owner = "returntocorp";
19
19
+
repo = "semgrep-langs";
20
20
+
rev = "78e518dad1ce2a7c76854c944245434bd8426439";
21
21
+
sha256 = "sha256-t9F/OzzT6FI9G4Fxz0lUjz6TVrJlenusQNJnFpiKaQs=";
22
22
+
};
23
23
+
24
24
+
interfacesSrc = fetchFromGitHub {
25
25
+
owner = "returntocorp";
26
26
+
repo = "semgrep-interfaces";
27
27
+
rev = "a64a45034ea428ecbe9da6bd849a4f1cfd23cdd2";
28
28
+
sha256 = "sha256-eatuyA5xyfZVHCmHvZIzQK2c5eEWUEZd9LumJQtk8+s=";
29
29
+
};
30
30
+
31
31
+
# fetch pre-built semgrep-core since the ocaml build is complex and relies on
32
32
+
# the opam package manager at some point
33
33
+
coreRelease = fetchzip {
34
34
+
url = "https://github.com/returntocorp/semgrep/releases/download/v${version}/semgrep-v${version}-ubuntu-16.04.tgz";
35
35
+
sha256 = "sha256-L3NbiVYmgJim7H4W1cr75WOItSiHT1YIkUEefuaCYlY=";
36
36
+
};
37
37
+
38
38
+
meta = with lib; {
39
39
+
homepage = "https://semgrep.dev/";
40
40
+
downloadPage = "https://github.com/returntocorp/semgrep/";
41
41
+
changelog = "https://github.com/returntocorp/semgrep/blob/v${version}/CHANGELOG.md";
42
42
+
description = "Lightweight static analysis for many languages";
43
43
+
longDescription = ''
44
44
+
Semgrep is a fast, open-source, static analysis tool for finding bugs and
45
45
+
enforcing code standards at editor, commit, and CI time. Semgrep analyzes
46
46
+
code locally on your computer or in your build environment: code is never
47
47
+
uploaded. Its rules look like the code you already write; no abstract
48
48
+
syntax trees, regex wrestling, or painful DSLs.
49
49
+
'';
50
50
+
license = licenses.lgpl21Plus;
51
51
+
maintainers = with maintainers; [ jk ambroisie ];
52
52
+
# limited by semgrep-core
53
53
+
platforms = [ "x86_64-linux" ];
54
54
+
};
55
55
+
}
+81
pkgs/tools/security/semgrep/default.nix
···
1
1
+
{ lib
2
2
+
, fetchFromGitHub
3
3
+
, callPackage
4
4
+
, semgrep-core
5
5
+
, buildPythonApplication
6
6
+
, pythonPackages
7
7
+
8
8
+
, pytestCheckHook
9
9
+
, git
10
10
+
}:
11
11
+
12
12
+
let
13
13
+
common = callPackage ./common.nix { };
14
14
+
in
15
15
+
buildPythonApplication rec {
16
16
+
pname = "semgrep";
17
17
+
inherit (common) version;
18
18
+
src = "${common.src}/cli";
19
19
+
20
20
+
SEMGREP_CORE_BIN = "${semgrep-core}/bin/semgrep-core";
21
21
+
22
22
+
postPatch = ''
23
23
+
substituteInPlace setup.py \
24
24
+
--replace "typing-extensions~=4.2" "typing-extensions" \
25
25
+
--replace "jsonschema~=3.2" "jsonschema" \
26
26
+
--replace "boltons~=21.0" "boltons"
27
27
+
28
28
+
# remove git submodule placeholders
29
29
+
rm -r ./src/semgrep/{lang,semgrep_interfaces}
30
30
+
# link submodule dependencies
31
31
+
ln -s ${common.langsSrc}/ ./src/semgrep/lang
32
32
+
ln -s ${common.interfacesSrc}/ ./src/semgrep/semgrep_interfaces
33
33
+
'';
34
34
+
35
35
+
doCheck = true;
36
36
+
checkInputs = [ git pytestCheckHook ] ++ (with pythonPackages; [
37
37
+
pytest-snapshot
38
38
+
pytest-mock
39
39
+
pytest-freezegun
40
40
+
types-freezegun
41
41
+
]);
42
42
+
disabledTests = [
43
43
+
# requires networking
44
44
+
"tests/unit/test_metric_manager.py"
45
45
+
];
46
46
+
preCheck = ''
47
47
+
# tests need a home directory
48
48
+
export HOME="$(mktemp -d)"
49
49
+
50
50
+
# disabledTestPaths doesn't manage to avoid the e2e tests
51
51
+
# remove them from pyproject.toml
52
52
+
# and remove need for pytest-split
53
53
+
substituteInPlace pyproject.toml \
54
54
+
--replace '"tests/e2e",' "" \
55
55
+
--replace 'addopts = "--splitting-algorithm=least_duration"' ""
56
56
+
'';
57
57
+
58
58
+
propagatedBuildInputs = with pythonPackages; [
59
59
+
attrs
60
60
+
boltons
61
61
+
colorama
62
62
+
click
63
63
+
click-option-group
64
64
+
glom
65
65
+
requests
66
66
+
ruamel-yaml
67
67
+
tqdm
68
68
+
packaging
69
69
+
jsonschema
70
70
+
wcmatch
71
71
+
peewee
72
72
+
defusedxml
73
73
+
urllib3
74
74
+
typing-extensions
75
75
+
python-lsp-jsonrpc
76
76
+
];
77
77
+
78
78
+
meta = common.meta // {
79
79
+
description = common.meta.description + " - cli";
80
80
+
};
81
81
+
}
+22
pkgs/tools/security/semgrep/semgrep-core.nix
···
1
1
+
{ lib, stdenvNoCC, callPackage }:
2
2
+
3
3
+
let
4
4
+
common = callPackage ./common.nix { };
5
5
+
in
6
6
+
stdenvNoCC.mkDerivation rec {
7
7
+
pname = "semgrep-core";
8
8
+
inherit (common) version;
9
9
+
10
10
+
src = common.coreRelease;
11
11
+
12
12
+
installPhase = ''
13
13
+
runHook preInstall
14
14
+
install -Dm 755 -t $out/bin semgrep-core
15
15
+
runHook postInstall
16
16
+
'';
17
17
+
18
18
+
meta = common.meta // {
19
19
+
description = common.meta.description + " - core binary";
20
20
+
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
21
21
+
};
22
22
+
}
+3
pkgs/top-level/all-packages.nix
···
10437
10437
10438
10438
seexpr = callPackage ../development/compilers/seexpr { };
10439
10439
10440
10440
+
semgrep = python3.pkgs.callPackage ../tools/security/semgrep { };
10441
10441
+
semgrep-core = callPackage ../tools/security/semgrep/semgrep-core.nix { };
10442
10442
+
10440
10443
setroot = callPackage ../tools/X11/setroot { };
10441
10444
10442
10445
setserial = callPackage ../tools/system/setserial { };