From 41a2d5077305f29036fe7a8525f116c9abfae07e Mon Sep 17 00:00:00 2001 From: Fadi Abbud Date: Mon, 7 Mar 2022 14:39:29 +0100 Subject: [PATCH] Code documentation --- cmd/csaf_checker/main.go | 6 ++++++ cmd/csaf_checker/processor.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/cmd/csaf_checker/main.go b/cmd/csaf_checker/main.go index f1535a0..0e5a572 100644 --- a/cmd/csaf_checker/main.go +++ b/cmd/csaf_checker/main.go @@ -38,6 +38,8 @@ func errCheck(err error) { } } +// writeJSON writes the JSON encoding of the given report to the given stream. +// It returns nil, otherwise an error. func writeJSON(report *Report, w io.WriteCloser) error { enc := json.NewEncoder(w) enc.SetIndent("", " ") @@ -48,6 +50,8 @@ func writeJSON(report *Report, w io.WriteCloser) error { return err } +// writeHTML writes the given report to the given writer, it uses the template +// in the "reportHTML" variable. It returns nil, otherwise an error. func writeHTML(report *Report, w io.WriteCloser) error { tmpl, err := template.New("Report HTML").Parse(reportHTML) if err != nil { @@ -72,6 +76,8 @@ type nopCloser struct{ io.Writer } func (nc *nopCloser) Close() error { return nil } +// writeReport defines where to write the report according to the "output" flag options. +// It calls also the "writeJSON" or "writeHTML" function according to the "format" flag option. func writeReport(report *Report, opts *options) error { var w io.WriteCloser diff --git a/cmd/csaf_checker/processor.go b/cmd/csaf_checker/processor.go index 1a4bd4e..fb88608 100644 --- a/cmd/csaf_checker/processor.go +++ b/cmd/csaf_checker/processor.go @@ -182,6 +182,8 @@ func (p *processor) checkDomain(domain string) error { return nil } +// checkTLS parses the given URL to check its schema, as a result set +// the value of "noneTLS" field if it is not HTTPS. func (p *processor) checkTLS(u string) { if p.noneTLS == nil { p.noneTLS = map[string]struct{}{}