1
+ ---
2
+ version : v1
3
+ release_phase : alpha
4
+ type : rule-type
5
+ name : osps-do-03
6
+ display_name : OSPS-DO-03 The project documentation MUST provide user guides for all basic functionality
7
+ short_failure_message : No user guides or project documentation found
8
+ severity :
9
+ value : low
10
+ context :
11
+ provider : github
12
+ description : |
13
+ Verifies that the project documentation provides a user guide
14
+ guidance : |
15
+ This rule attempts to locate user guides from several project documentation sources.
16
+
17
+ Currently, this rule checks the following:
18
+
19
+ * The GitHub repository's public link
20
+ * A `docs` directory in the default branch of the repository with .md, .rst, .html or .txt files
21
+ * A `README.md` file containing preformatted text (triple-backtick) or the headings
22
+ "usage" or "getting started"
23
+
24
+ For more information, see [OpenSSF Security Baseline](https://baseline.openssf.org/#osps-do-03).
25
+ def :
26
+ in_entity : repository
27
+ rule_schema : {}
28
+ ingest :
29
+ type : git
30
+ eval :
31
+ type : rego
32
+ data_sources :
33
+ - name : ghapi
34
+ rego :
35
+ type : deny-by-default
36
+ def : |
37
+ package minder
38
+
39
+ import rego.v1
40
+
41
+ default allow := false
42
+
43
+ repo := sprintf("%s/%s", [])
44
+
45
+ allow if {
46
+ # Check the GitHub homepage link
47
+ out = minder.datasource.ghapi.repo({
48
+ "owner": input.properties["github/repo_owner"],
49
+ "repo": input.properties["github/repo_name"]
50
+ })
51
+ out.homepage != ""
52
+ }
53
+
54
+ allow if {
55
+ # Check the docs directory
56
+ mdDocs := file.ls_glob("docs/*.md")
57
+ rstDocs := file.ls_glob("docs/*.rst")
58
+ htmlDocs := file.ls_glob("docs/*.html")
59
+ txtDocs := file.ls_glob("docs/*.txt")
60
+ count(mdDocs) + count(rstDocs) + count(htmlDocs) + count(txtDocs) > 0
61
+ }
62
+
63
+ readme := file.read("README.md")
64
+ allow if {
65
+ # Check the README.md file for preformatted text after the first line
66
+ regex.match("\n *```", readme)
67
+ }
68
+ allow if {
69
+ regex.match("\n#+ (?i:Usage|Getting Started)", readme)
70
+ }
71
+ remediate :
72
+ type : pull_request
73
+ pull_request :
74
+ title : " Add documentation to security-insights.yaml"
75
+ body : |
76
+ This is a Minder automated pull request.
77
+
78
+ This pull request links the discovered documentation in the security-insights.yaml file.
79
+ method : minder.yq.evaluate
80
+ params :
81
+ # TODO: need to be able to feed output from eval into remediate
82
+ expression : |
83
+ .documentation = [ "./README.md" ]
84
+ patterns :
85
+ # TODO: need to be able to create files as well as match existing files
86
+ - pattern : " SECURITY-INSIGHTS.yaml"
87
+ type : glob
0 commit comments