opencontrol / compliance-masonry

Security Documentation Builder
Other
350 stars 82 forks source link

Added rational sort order for Justifications, Verifications, and Components #334

Closed riskpeep closed 5 years ago

riskpeep commented 5 years ago

Added natural sort for justifications and verifications. Added sort by key for components

Provides rational sort order for generated gitbook documents.

codecov[bot] commented 5 years ago

Codecov Report

Merging #334 into master will decrease coverage by 0.16%. The diff coverage is 55.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
- Coverage   79.06%   78.89%   -0.17%     
==========================================
  Files          38       38              
  Lines        1428     1436       +8     
==========================================
+ Hits         1129     1133       +4     
- Misses        246      250       +4     
  Partials       53       53
Impacted Files Coverage Δ
pkg/lib/result/justifications.go 75.86% <100%> (+0.86%) :arrow_up:
pkg/lib/common/verifications.go 66.66% <100%> (ø) :arrow_up:
pkg/lib/components.go 87.5% <42.85%> (-7.63%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b3f60cb...71009b3. Read the comment docs.

codecov[bot] commented 5 years ago

Codecov Report

Merging #334 into master will increase coverage by 0.11%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #334      +/-   ##
==========================================
+ Coverage   79.06%   79.17%   +0.11%     
==========================================
  Files          38       38              
  Lines        1428     1436       +8     
==========================================
+ Hits         1129     1137       +8     
  Misses        246      246              
  Partials       53       53
Impacted Files Coverage Δ
pkg/lib/common/verifications.go 66.66% <100%> (ø) :arrow_up:
pkg/lib/result/justifications.go 75.86% <100%> (+0.86%) :arrow_up:
pkg/lib/components.go 95.83% <100%> (+0.71%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1891cff...c3a7f6b. Read the comment docs.

shawndwells commented 5 years ago

@riskpeep Thanks for this! Just fixed some of the appveyor issues through https://github.com/opencontrol/compliance-masonry/pull/335. Could you rebase, which will (re)test this PR?

riskpeep commented 5 years ago

When considering the pull request, pay some attention to the edits to parse_test https://github.com/opencontrol/compliance-masonry/pull/334/commits/8d2805efe36f40183854813b7c8fe572fd882a27

I had to make those edits to get the appveyor build to pass. The same tests passed w/o those edits on my Linux dev box and none of the other edits for this PR should have impacted the code in parse.go, so I'm not 100% sure why appveyor complained and my local 'make test' did not.

redhatrises commented 5 years ago

@riskpeep sorry for late reply on this... Code looks good and tests are passing.

@shawndwells can you build some opencontrol content with this PR and see if anything breaks at the content layer?

shawndwells commented 5 years ago
$ git checkout -b riskpeep-dev-sort-order master
Switched to a new branch 'riskpeep-dev-sort-order'

$ git pull https://github.com/riskpeep/compliance-masonry.git dev-sort-order
remote: Enumerating objects: 14, done.
remote: Counting objects: 100% (14/14), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 14 (delta 10), reused 14 (delta 10), pack-reused 0
Unpacking objects: 100% (14/14), done.
From https://github.com/riskpeep/compliance-masonry
 * branch            dev-sort-order -> FETCH_HEAD
Updating 1891cff..c3a7f6b
Fast-forward
 pkg/lib/common/verifications.go       |  6 +++++-
 pkg/lib/common/verifications_test.go  |  4 +++-
 pkg/lib/components.go                 | 15 +++++++++++++++
 pkg/lib/components_test.go            | 19 +++++++++++++++++++
 pkg/lib/opencontrol/parse_test.go     | 18 +++++++++---------
 pkg/lib/result/justifications.go      |  2 ++
 pkg/lib/result/justifications_test.go | 27 +++++++++++++++++++++++++++
 7 files changed, 80 insertions(+), 11 deletions(-)

$ make
go build -gcflags="-N -l" -ldflags="-s -w -X github.com/opencontrol/compliance-masonry/version.Version=1.1.5 -X github.com/opencontrol/compliance-masonry/version.Commit=c3a7f6b -X github.com/opencontrol/compliance-masonry/version.Date=2018-12-10T22:31:53+0000"\
        -o _output/masonry \
        cmd/masonry/masonry.go
go build -gcflags="-N -l" -ldflags="-s -w -X github.com/opencontrol/compliance-masonry/version.Version=1.1.5 -X github.com/opencontrol/compliance-masonry/version.Commit=c3a7f6b -X github.com/opencontrol/compliance-masonry/version.Date=2018-12-10T22:31:53+0000"\
                -o _output/compliance-masonry \
                cmd/compliance-masonry/compliance-masonry.go

for testing, using the following opencontrol.yaml:

$ cat opencontrol.yaml
schema_version: "1.0.0"
name: Template Information System
metadata:
  description: Template Information System
  maintainers:
    - Shawn Wells <shawn@redhat.com>

components:
#    - ./../../ComplianceAsCode/redhat-openstack-platform-13
#    - ./../../ComplianceAsCode/redhat-openshift-v3
#    - ./../../ComplianceAsCode/redhat/ansible-tower

dependencies:
  standards:
    - url: https://github.com/opencontrol/standards
      revision: master
  certifications:
    - url: https://github.com/opencontrol/certifications
      revision: master
  systems:
#    - url: https://github.com/SecurityCentral/template-system-process-controls
#      revision: opencontrol
    - url: https://github.com/ComplianceAsCode/redhat
      contextdir: osp13
      revision: opencontrol
    - url: https://github.com/ComplianceAsCode/redhat
      contextdir: ocp3
      revision: opencontrol
    - url: https://github.com/ComplianceAsCode/redhat
      contextdir: idm
      revision: opencontrol
    - url: https://github.com/ComplianceAsCode/redhat
      contextdir: ansible-tower
      revision: opencontrol
    - url: https://github.com/ComplianceAsCode/redhat
      contextdir: rhvm
      revision: opencontrol
    - url: https://github.com/ComplianceAsCode/redhat
      contextdir: rhvh
      revision: opencontrol

and attempting a fetch/get:

$ /Users/shawnwells/Documents/github/opencontrol/compliance-masonry/_output/compliance-masonry get
An error occurred: readdirent: invalid argument
shawndwells commented 5 years ago

@riskpeep @redhatrises looks like masonry has errors, but may reflect something from upstream vs this patch

shawndwells commented 5 years ago

this is on OSX with golang 1.10.1

redhatrises commented 5 years ago

@riskpeep @redhatrises looks like masonry has errors, but may reflect something from upstream vs this patch

@shawndwells I am not seeing the error that you are getting. I wonder if it is an issue with golang 1.10.1? Seems to work for me.

shawndwells commented 5 years ago

upgraded golang to 1.11.4 and this works now

shawndwells commented 5 years ago

thanks, @riskpeep!