lib

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: CC0-1.0 Imports: 14 Imported by: 22

README

Lib Package

GoDoc

Purpose

This package (and the sub packages) are the only packages that should be imported by external projects. This lib package is very helpful for those writing plugins to extend the functionality of Masonry.

Additionally, 1) the pkg/lib/common package contains all the interfaces for workspace information and 2) the pkg/lib/common/mocks contains all the mocks to help with tests.

The idea is once you run the get command and all the resources (YAML, etc) are placed in a folder, those resources can be loaded into a Workspace via code and you'll have access to all of that info.

Development

Usage

There are many interfaces but the main ones are:

Workspace

Workspace is the representation of your working space with all the resources gathered together.

  • How to obtain a workspace:
    import "github.com/opencontrol/compliance-masonry/pkg/lib"
    
    // some other code
    
    ws := lib.LoadData("where-get-command-placed-things", "certification-path")
    
Standard

Standard is representation of all the controls for a certain standard (e.g. NIST-800-53).

Once you have a workspace object, you can use GetStandard and provide a standard key. For more information about the key value to used or more information about standards, refer to the standard schema.

Component

Component is a basic block of compliance information that corresponds to a control or set of controls.

Once you have a workspace object, you can use GetAllComponents or GetComponentand provide a component key. For more information about the key value to used or more information about the component, refer to the component schema.

Certification

Certification is a list of controls that make up a certain "certification".

Once you have a workspace object, you can use GetCertification. For more information about the certification, refer to the certification schema.

Result Data

Verification is a data structure that is not represented in yaml but rather a post-processed map of data to help quickly getting component data for a particular control name - standard name combination.

Mock generation

The pkg/lib/common/mocks is a package that is auto-generated via mockery. Follow the instructions there to install mockery.

Whenever a modification is made to an existing interface or a new interface is created, you should use mockery to (re)generate the mock while inside the pkg/lib/common folder.

mockery -name NameOfInterface
# Example:
mockery -name Workspace

Plugin Developer Guide

Developers should not have to worry about loading real data / workspaces for their unit tests (they should for integration tests).

There is an example of developing your Go plugin and tests in exampleplugin/example.go and exampleplugin/example_test.go respectively.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadData

func LoadData(openControlDir string, certificationPath string) (common.Workspace, []error)

LoadData creates a new instance of OpenControl struct and loads the components, standards, and certification data.

func NewWorkspace

func NewWorkspace() common.Workspace

NewWorkspace initializes an empty OpenControl struct

Types

This section is empty.

Directories

Path Synopsis
mocks
Code generated by mockery v1.0.0.
Code generated by mockery v1.0.0.

Jump to

Keyboard shortcuts

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