report

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Report

A package for generating reports from a list of packages []listen.Packages.

It can generate reports in the following formats:

  • JSON: report.NewJSONReport()
  • Markdown: report.NewFullMarkdwonReport()

Example

package main

import (
	"log"
	"os"

	"github.com/listendev/lstn/pkg/cmd/report"
	"github.com/listendev/lstn/pkg/listen"
)

func main() {
	// json report
	jsonReport := report.NewJSONReport()

	// json report
	jsonReportFile, err := os.Create("/tmp/report.json")
	if err != nil {
		log.Fatal(err)
	}
	defer jsonReportFile.Close()
	jsonReport.WithOutput(jsonReportFile)

	// full markdown report
	fullMarkdownReport := report.NewFullMarkdwonReport()
	fullMDReportFile, err := os.Create("/tmp/report.md")
	if err != nil {
		log.Fatal(err)
	}
	fullMarkdownReport.WithOutput(fullMDReportFile)

	rb := report.NewBuilder()
	rb.RegisterReport(jsonReport)
	rb.RegisterReport(fullMarkdownReport)

	packages := []listen.Package{
		{
			Name:    "react",
			Version: "1.0.0",
			Verdicts: []listen.Verdict{
				{
					Message:  "unexpected outbound connection destination",
					Severity: "high",
					Metadata: map[string]interface{}{
						"commandline":      "/usr/local/bin/node",
						"file_descriptor:": "10.0.2.100:47326->142.251.111.128:0",
						"server_ip":        "142.251.111.128",
						"executable_path":  "/usr/local/bin/node",
					},
				},
			},
			Problems: []listen.Problem{},
		},
	}
	rb.Render(packages)
}

Documentation

Overview

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

SPDX-License-Identifier: Apache-2.0

Copyright © 2023 The listen.dev team <engineering@garnet.ai>

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.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FullMarkdwonReport

type FullMarkdwonReport struct {
	// contains filtered or unexported fields
}

func NewFullMarkdwonReport

func NewFullMarkdwonReport() *FullMarkdwonReport

func (*FullMarkdwonReport) Render

func (r *FullMarkdwonReport) Render(packages []listen.Package) error

func (*FullMarkdwonReport) WithOutput

func (r *FullMarkdwonReport) WithOutput(w io.Writer)

type JSONReport

type JSONReport struct {
	// contains filtered or unexported fields
}

func NewJSONReport

func NewJSONReport() *JSONReport

func (*JSONReport) Render

func (r *JSONReport) Render(packages []listen.Package) error

func (*JSONReport) WithOutput

func (r *JSONReport) WithOutput(w io.Writer)

type Renderer

type Renderer interface {
	Render(packages []listen.Package) error
}

type Report

type Report struct {
	// contains filtered or unexported fields
}

func NewBuilder

func NewBuilder() *Report

func (*Report) RegisterReport

func (b *Report) RegisterReport(r Report)

func (*Report) Render

func (b *Report) Render(packages []listen.Package) error

Directories

Path Synopsis
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL