mirror of
https://github.com/ossf/scorecard.git
synced 2024-09-19 21:18:09 +03:00
96 lines
2.2 KiB
Go
96 lines
2.2 KiB
Go
|
// Copyright 2020 Security Scorecard Authors
|
||
|
//
|
||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
// you may not use this file except in compliance with the License.
|
||
|
// You may obtain a copy of the License at
|
||
|
//
|
||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||
|
//
|
||
|
// Unless required by applicable law or agreed to in writing, software
|
||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
// See the License for the specific language governing permissions and
|
||
|
// limitations under the License.
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"sort"
|
||
|
|
||
|
"gopkg.in/yaml.v2"
|
||
|
)
|
||
|
|
||
|
type doc struct {
|
||
|
Description string `yaml:"description"`
|
||
|
Remediation []string `yaml:"remediation"`
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
yamlFile, err := os.Open("../checks.yaml")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
defer yamlFile.Close()
|
||
|
|
||
|
byteValue, err := ioutil.ReadAll(yamlFile)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
m := make(map[string]map[string]doc)
|
||
|
err = yaml.Unmarshal(byteValue, &m)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
keys := make([]string, 0, len(m["checks"]))
|
||
|
for k := range m["checks"] {
|
||
|
keys = append(keys, k)
|
||
|
}
|
||
|
sort.Strings(keys)
|
||
|
|
||
|
f, err := os.Create("../checks.md")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
defer f.Close()
|
||
|
_, err = f.WriteString(`
|
||
|
<!-- Do not edit this file manually! Edit checks.yaml instead. -->
|
||
|
# Check Documentation
|
||
|
|
||
|
This page contains information on how each check works and provide remediation
|
||
|
steps to fix the failure. All of these checks are basically "best-guesses"
|
||
|
currently, and operate on a set of heuristics.
|
||
|
|
||
|
They are all subject to change, and have room for improvement!
|
||
|
If you have ideas for things to add, or new ways to detect things,
|
||
|
please contribute!
|
||
|
`)
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
for _, k := range keys {
|
||
|
_, err = f.WriteString("## " + k + " \n\n")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
_, err = f.WriteString(m["checks"][k].Description + " \n\n")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
_, err = f.WriteString("**Remediation steps**\n")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
for _, r := range m["checks"][k].Remediation {
|
||
|
_, err = f.WriteString("- " + r + "\n")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|
||
|
_, err = f.WriteString("\n")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
}
|
||
|
}
|