Skip to content

Commit fc057cd

Browse files
committed
Update docs with newly-added rego functions
1 parent 0068f4d commit fc057cd

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

docs/docs/how-to/writing-rules-in-rego.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,29 @@ Note that these are known patterns in the OPA community, so we’re not doing an
3030

3131
Given the context in which Minder operates, we did need to add some custom functionality that OPA doesn’t provide out of the box. Namely, we added the following custom functions:
3232

33-
* **file.exists**: Verifies that the given file exists in the Git repository.
33+
* **file.exists(filepath)**: Verifies that the given filepath exists in the Git repository, returns a boolean.
3434

35-
* **file.read**: Reads the contents of the given file in the Git repository.
35+
* **file.read(filepath)**: Reads the contents of the given file in the Git repository and returns the contents as a string.
3636

37-
* **file.ls**: Lists files in the given directory in the Git repository.
37+
* **file.ls(directory)**: Lists files in the given directory in the Git repository, returning the filenames as an array of strings.
3838

39-
* **file.ls_glob**: Lists files in the given directory in the Git repository that match the given glob pattern.
39+
* **file.ls_glob(pattern)**: Lists files in the given directory in the Git repository that match the given glob pattern, returning matched filenames as an array of strings.
4040

41-
* **file.http_type**: Returns the HTTP content type of the given file.
41+
* **file.http_type(filepath)**: Determines the HTTP (MIME) content type of the given file by [examining the first 512 bytes of the file](https://mimesniff.spec.whatwg.org/). It returns the content type as a string.
4242

43-
* **file.walk**: Walks the given directory in the Git repository and lists all files.
43+
* **file.walk(path)**: Walks the given path (directory or file) in the Git repository and returns a list of paths to all regular files (not directories) as an array of strings.
4444

45-
* **github_workflow.ls_actions**: Lists all actions in the given GitHub workflow directory.
45+
* **github_workflow.ls_actions(directory)**: Lists all actions in the given GitHub workflow directory, returning the filenames as an array of strings.
46+
47+
* **parse_yaml**: Parses a YAML string into a JSON object. This implementation uses https://gopkg.in/yaml.v3, which avoids bugs when parsing `"on"` as an object _key_ (for example, in GitHub workflows).
48+
49+
* **jq.is_true(object, query)**: Evaluates a jq query against the specified object, returning `true` if the query result is a true boolean value, andh `false` otherwise.
50+
51+
* **file.archive(paths)**: _(experimental)_ Builds a `.tar.gz` format archive containing all files under the given paths. Returns the archive contents as a (binary) string.
52+
53+
_(experimental)_ In addition, when operating in a pull request context, `base_file` versions of the `file` operations are available for accessing the files in the base branch of the pull request. The `file` versions of the operations operate on the head (proposed changes) versions of the files in a pull request context.
54+
55+
In addition, most of the [standard OPA functions are available in the Minder runtime](https://www.openpolicyagent.org/docs/latest/policy-reference/#built-in-functions).
4656

4757
## Example: CodeQL-Enabled Check
4858

0 commit comments

Comments
 (0)