Skip to content

Commit

Permalink
License header
Browse files Browse the repository at this point in the history
  • Loading branch information
DarthHater committed Apr 10, 2020
1 parent faf25e5 commit 7ed3e3d
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 8 deletions.
13 changes: 13 additions & 0 deletions audit/auditlogtextformatter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2020 Sonatype Inc.
//
// 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 audit

import (
Expand Down
16 changes: 15 additions & 1 deletion audit/auditlogtextformatter_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
// Copyright 2020 Sonatype Inc.
//
// 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 audit

import (
"errors"
"testing"

. "github.com/sirupsen/logrus"
"github.com/sonatype-nexus-community/nancy/types"
"github.com/stretchr/testify/assert"
"testing"
)

func TestFormatterErrorsIfEntryNotValid(t *testing.T) {
Expand Down
20 changes: 17 additions & 3 deletions audit/csvformatter.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
// Copyright 2020 Sonatype Inc.
//
// 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 audit

import (
"bytes"
"encoding/csv"
"encoding/json"
"errors"
"strconv"

. "github.com/sirupsen/logrus"
"github.com/sonatype-nexus-community/nancy/types"
"strconv"
)

type CsvFormatter struct {
Quiet *bool
Quiet *bool
}

func (f *CsvFormatter) Format(entry *Entry) ([]byte, error) {
Expand Down Expand Up @@ -43,7 +57,7 @@ func (f *CsvFormatter) Format(entry *Entry) ([]byte, error) {
w.Write(summaryHeader)
w.Write(summaryRow)

if (!*f.Quiet) {
if !*f.Quiet {
invalidCount := len(invalidEntries)
if invalidCount > 0 {
w.Write([]string{""})
Expand Down
18 changes: 16 additions & 2 deletions audit/csvformatter_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
// Copyright 2020 Sonatype Inc.
//
// 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 audit

import (
"errors"
"testing"

. "github.com/sirupsen/logrus"
"github.com/sonatype-nexus-community/nancy/types"
"github.com/stretchr/testify/assert"
"testing"
)

func TestCsvOutputWhenQuiet(t *testing.T) {
Expand Down Expand Up @@ -57,7 +71,7 @@ func TestCsvOutput(t *testing.T) {
formatter := CsvFormatter{Quiet: &quiet}
logMessage, e := formatter.Format(&entry)
assert.Nil(t, e)
expectedCsv := `Summary
expectedCsv := `Summary
Audited Count,Vulnerable Count,Build Version
2,1,development
Expand Down
13 changes: 13 additions & 0 deletions audit/jsonformatter.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2020 Sonatype Inc.
//
// 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 audit

import (
Expand Down
16 changes: 15 additions & 1 deletion audit/jsonformatter_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
// Copyright 2020 Sonatype Inc.
//
// 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 audit

import (
"testing"

. "github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"testing"
)

func TestJsonOutpu(t *testing.T) {
Expand Down
13 changes: 13 additions & 0 deletions buildversion/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// Copyright 2020 Sonatype Inc.
//
// 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 buildversion

var (
Expand Down
16 changes: 15 additions & 1 deletion buildversion/version_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
// Copyright 2020 Sonatype Inc.
//
// 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 buildversion

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestDefaultVersion(t *testing.T) {
Expand Down

0 comments on commit 7ed3e3d

Please sign in to comment.