Skip to content

Commit cca0dee

Browse files
committed
Merge branch 'main' into continue-webhook
2 parents 8d7691a + 97c20c0 commit cca0dee

47 files changed

Lines changed: 804 additions & 134 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dagger/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const (
2626
GOLANGCILINT_VERSION = "v2.1.2"
2727
GO_VERSION = "1.24.2"
2828
SYFT_VERSION = "v1.9.0"
29-
GORELEASER_VERSION = "v2.3.2"
29+
GORELEASER_VERSION = "v2.8.2"
3030
)
3131

3232
func New(
@@ -228,7 +228,7 @@ func (m *HarborCli) PublishImage(
228228
// SnapshotRelease Create snapshot non OCI artifacts with goreleaser
229229
func (m *HarborCli) SnapshotRelease(ctx context.Context) *dagger.Directory {
230230
return m.goreleaserContainer().
231-
WithExec([]string{"goreleaser", "release", "--snapshot", "--clean", "--skip", "validate"}).
231+
WithExec([]string{"goreleaser", "release", "--snapshot", "--clean"}).
232232
Directory("/src/dist")
233233
}
234234

.github/workflows/default.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,24 @@ jobs:
9999
exit 1
100100
fi
101101
102+
test-release:
103+
runs-on: ubuntu-latest
104+
steps:
105+
- name: Checkout repo
106+
uses: actions/checkout@v4
107+
with:
108+
fetch-depth: 0
109+
110+
- name: Dagger Version
111+
uses: sagikazarmark/dagger-version-action@v0.0.1
112+
113+
- name: Test Release
114+
uses: dagger/dagger-for-github@v7
115+
with:
116+
version: ${{ steps.dagger_version.outputs.version }}
117+
verb: call
118+
args: snapshot-release
119+
102120
test-code:
103121
runs-on: ubuntu-latest
104122
steps:

cmd/harbor/root/artifact/list.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,18 @@ func ListArtifactCommand() *cobra.Command {
3030

3131
cmd := &cobra.Command{
3232
Use: "list",
33-
Short: "list artifacts within a repository",
34-
Args: cobra.MaximumNArgs(1),
33+
Short: "List container artifacts (images, charts, etc.) in a Harbor repository with metadata",
34+
Long: `List all artifacts (e.g., container images, charts) within a given Harbor repository.
35+
Supports optional project/repository input in the form <project>/<repository>.
36+
Displays key artifact metadata including tags, digest, type, size, vulnerability count, and push time.
37+
38+
Examples:
39+
harbor-cli artifact list # Interactive prompt for project and repository
40+
harbor-cli artifact list library/nginx # Directly list artifacts in the nginx repo under 'library' project
41+
42+
Supports pagination, search queries, and sorting using flags.`,
43+
44+
Args: cobra.MaximumNArgs(1),
3545
RunE: func(cmd *cobra.Command, args []string) error {
3646
if opts.PageSize > 100 {
3747
return fmt.Errorf("page size should be less than or equal to 100")

cmd/harbor/root/artifact/view.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func ViewArtifactCommmand() *cobra.Command {
2929
Use: "view",
3030
Short: "Get information of an artifact",
3131
Long: `Get information of an artifact`,
32-
Example: `harbor artifact view <project>/<repository>/<reference>`,
32+
Example: `harbor artifact view <project>/<repository>:<tag> OR harbor artifact view <project>/<repository>@<digest>`,
3333
Run: func(cmd *cobra.Command, args []string) {
3434
var err error
3535
var projectName, repoName, reference string
@@ -43,6 +43,14 @@ func ViewArtifactCommmand() *cobra.Command {
4343
reference = prompt.GetReferenceFromUser(repoName, projectName)
4444
}
4545

46+
if reference == "" {
47+
if len(args) > 0 {
48+
log.Errorf("Invalid artifact reference format: %s", args[0])
49+
} else {
50+
log.Error("Invalid artifact reference format: no arguments provided")
51+
}
52+
}
53+
4654
artifact, err = api.ViewArtifact(projectName, repoName, reference)
4755

4856
if err != nil {

cmd/harbor/root/cmd.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ import (
1919

2020
"github.com/goharbor/harbor-cli/cmd/harbor/root/artifact"
2121
"github.com/goharbor/harbor-cli/cmd/harbor/root/config"
22+
"github.com/goharbor/harbor-cli/cmd/harbor/root/cve"
2223
"github.com/goharbor/harbor-cli/cmd/harbor/root/instance"
2324
"github.com/goharbor/harbor-cli/cmd/harbor/root/labels"
2425
"github.com/goharbor/harbor-cli/cmd/harbor/root/project"
2526
"github.com/goharbor/harbor-cli/cmd/harbor/root/registry"
26-
repositry "github.com/goharbor/harbor-cli/cmd/harbor/root/repository"
27+
"github.com/goharbor/harbor-cli/cmd/harbor/root/repository"
2728
"github.com/goharbor/harbor-cli/cmd/harbor/root/schedule"
2829
"github.com/goharbor/harbor-cli/cmd/harbor/root/tag"
2930
"github.com/goharbor/harbor-cli/cmd/harbor/root/user"
@@ -96,11 +97,12 @@ harbor help
9697
config.Config(),
9798
project.Project(),
9899
registry.Registry(),
99-
repositry.Repository(),
100+
repository.Repository(),
100101
user.User(),
101102
artifact.Artifact(),
102103
tag.TagCommand(),
103104
HealthCommand(),
105+
cve.CVEAllowlist(),
104106
schedule.Schedule(),
105107
labels.Labels(),
106108
InfoCommand(),

cmd/harbor/root/cve/add.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package cve
15+
16+
import (
17+
"github.com/goharbor/harbor-cli/pkg/api"
18+
"github.com/goharbor/harbor-cli/pkg/views/cveallowlist/update"
19+
log "github.com/sirupsen/logrus"
20+
"github.com/spf13/cobra"
21+
)
22+
23+
func AddCveAllowlistCommand() *cobra.Command {
24+
var opts update.UpdateView
25+
26+
cmd := &cobra.Command{
27+
Use: "add",
28+
Short: "Add cve allowlist",
29+
Long: "Create allowlist of CVEs to ignore during vulnerability scanning",
30+
Run: func(cmd *cobra.Command, args []string) {
31+
var err error
32+
updateView := &update.UpdateView{
33+
CveId: opts.CveId,
34+
IsExpire: opts.IsExpire,
35+
ExpireDate: opts.ExpireDate,
36+
}
37+
38+
err = updatecveView(updateView)
39+
if err != nil {
40+
log.Errorf("failed to add cveallowlist: %v", err)
41+
}
42+
},
43+
}
44+
45+
flags := cmd.Flags()
46+
flags.BoolVarP(&opts.IsExpire, "isexpire", "i", false, "Indicates whether the CVE entries should have an expiration date. Set to true to specify an expiration date")
47+
flags.StringVarP(&opts.CveId, "cveid", "n", "", "Comma-separated list of CVE IDs to be added to the allowlist")
48+
flags.StringVarP(&opts.ExpireDate, "expiredate", "d", "", "Specifies the expiration date for the CVE entries in the format 'YYYY-MM-DD'")
49+
50+
return cmd
51+
}
52+
53+
func updatecveView(updateView *update.UpdateView) error {
54+
if updateView == nil {
55+
updateView = &update.UpdateView{}
56+
}
57+
58+
update.UpdateCveView(updateView)
59+
return api.UpdateSystemCve(*updateView)
60+
}

cmd/harbor/root/cve/cmd.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package cve
15+
16+
import (
17+
"github.com/spf13/cobra"
18+
)
19+
20+
func CVEAllowlist() *cobra.Command {
21+
cmd := &cobra.Command{
22+
Use: "cve-allowlist",
23+
Short: "Manage system CVE allowlist",
24+
Long: `Managing CVE lists that are intentionally excluded from vulnerability scanning`,
25+
Example: `harbor cve-allowlist list`,
26+
}
27+
cmd.AddCommand(
28+
ListCveCommand(),
29+
AddCveAllowlistCommand(),
30+
)
31+
32+
return cmd
33+
}

cmd/harbor/root/cve/list.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright Project Harbor Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
package cve
15+
16+
import (
17+
"github.com/goharbor/harbor-cli/pkg/api"
18+
"github.com/goharbor/harbor-cli/pkg/utils"
19+
"github.com/goharbor/harbor-cli/pkg/views/cveallowlist/list"
20+
log "github.com/sirupsen/logrus"
21+
"github.com/spf13/cobra"
22+
"github.com/spf13/viper"
23+
)
24+
25+
func ListCveCommand() *cobra.Command {
26+
cmd := &cobra.Command{
27+
Use: "list",
28+
Short: "List system level allowlist of cve",
29+
Args: cobra.NoArgs,
30+
Run: func(cmd *cobra.Command, args []string) {
31+
cve, err := api.ListSystemCve()
32+
if err != nil {
33+
log.Fatalf("failed to get system cve list: %v", err)
34+
}
35+
FormatFlag := viper.GetString("output-format")
36+
if FormatFlag != "" {
37+
err = utils.PrintFormat(cve, FormatFlag)
38+
if err != nil {
39+
log.Fatalf("failed to print cve list: %v", err)
40+
return
41+
}
42+
} else {
43+
list.ListSystemCve(cve.Payload)
44+
}
45+
},
46+
}
47+
48+
return cmd
49+
}

dagger.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "harbor-cli",
3-
"engineVersion": "v0.18.3",
3+
"engineVersion": "v0.18.4",
44
"sdk": {
55
"source": "go"
66
},

doc/cli-docs/harbor-artifact-delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ harbor artifact delete [flags]
2121
### Options inherited from parent commands
2222

2323
```sh
24-
--config string config file (default is $HOME/.harbor/config.yaml) (default "/home/user/.harbor/config.yaml")
24+
-c, --config string config file (default is $HOME/.config/harbor-cli/config.yaml)
2525
-o, --output-format string Output format. One of: json|yaml
2626
-v, --verbose verbose output
2727
```

0 commit comments

Comments
 (0)