forked from semgrep/semgrep
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
capabilities: forbid fork() and start use Cap.fork (semgrep/semgrep-p…
…roprietary#2118) test plan: make test synced from Pro 904da30960c05633f22650f67f25d72ff2d9ae87
- Loading branch information
Showing
6 changed files
with
43 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
let execvp _caps = Unix.execvp | ||
let system _caps = Unix.system | ||
let fork _caps = Unix.fork |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// See also forbid_{exec,exit,chdir}.jsonnet | ||
local common = import 'common.libsonnet'; | ||
|
||
local unix_funcs = [ | ||
'fork', | ||
//TODO: alarm, signal, kill, waitpid | ||
]; | ||
|
||
{ | ||
rules: [ | ||
{ | ||
id: 'forbid-process', | ||
match: { any: | ||
// Unix | ||
[('Unix.' + p) for p in unix_funcs] + | ||
[('UUnix.' + p) for p in unix_funcs] + | ||
//TODO Other libs? | ||
[] | ||
}, | ||
languages: ['ocaml'], | ||
paths: { | ||
exclude: common.exclude_paths | ||
}, | ||
severity: 'ERROR', | ||
message: ||| | ||
Do not use directly process functions. Use the | ||
safer CapProcess module. | ||
|||, | ||
}, | ||
], | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
(* | ||
* Important note about exception: | ||
* from marshal.mli in the OCaml stdlib: | ||
* "Values of extensible variant types, for example exceptions (of | ||
* extensible type [exn]), returned by the unmarshaller should not be | ||
* pattern-matched over through [match ... with] or [try ... with], | ||
* because unmarshalling does not preserve the information required for | ||
* matching their constructors. Structural equalities with other | ||
* extensible variant values does not work either. Most other uses such | ||
* as Printexc.to_string, will still work as expected." | ||
* The unit argument is actually so that a call to | ||
* [invoke_in_child_process caps f args] can return a promise on the result. | ||
*) | ||
|
||
val invoke_in_child_process : ('a -> 'b) -> 'a -> unit -> 'b | ||
val apply_in_child_process : < Cap.fork > -> ('a -> 'b) -> 'a -> unit -> 'b |