forked from semgrep/semgrep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforbid_console.jsonnet
58 lines (54 loc) · 1.38 KB
/
forbid_console.jsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local common = import 'common.libsonnet';
local stdlib_funcs = [
'print_string'
//TODO: many more
];
local unix_funcs = [
'stdout',
//TODO: many more
];
{
rules: [
{
id: 'forbid-console',
match: { any:
// Stdlib
[p for p in stdlib_funcs] +
[('Stdlib.' + p) for p in stdlib_funcs] +
[('UStdlib.' + p) for p in stdlib_funcs] +
// Unix
[('Unix.' + p) for p in unix_funcs] +
[('UUnix.' + p) for p in unix_funcs] +
// Printf
['Printf.printf'] +
// Format
['Format.std_formatter'] +
// Fmt
['Fmt.pr', 'Fmt.stdout'] +
// Ocolor
['Ocolor_format.printf']
//TODO 'UConsole.$F'
//TODO 'UCommon.pr' 'UCommon.pr2', ...
},
languages: ['ocaml'],
paths: {
exclude: common.exclude_paths +
['UConsole.ml', 'CapConsole.ml'] +
// TODO: remove!
['common2.ml','UCommon.ml',
'Console_Spinner.ml',
'Dump.ml', 'Print_match.ml', 'Dump_match.ml', 'Trace_matching.ml',
'test/Matcher.ml',
'test_py_python_str_repr.ml',
'Boilerplate_tree_sitter_typescript.ml'
]
,
},
severity: 'ERROR',
message: |||
Do not output directly to the console. Either use a formatter or use the
safer CapConsole.print() function.
|||,
},
],
}