Skip to content

Commit 3717385

Browse files
authored
Merge branch 'goharbor:main' into optimizer-adapter
2 parents 6085ebe + ca62147 commit 3717385

76 files changed

Lines changed: 20936 additions & 20198 deletions

File tree

Some content is hidden

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

.github/dependabot.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ updates:
2323
reviewers:
2424
- "OrlinVasilev"
2525
groups:
26+
# codeql-analysis.yml runs codeql-action/init and codeql-action/analyze
27+
# in one job. init writes a config file stamped with its version and
28+
# analyze rejects it from any other version, so both must be bumped
29+
# in the same pull request.
30+
codeql-action:
31+
patterns:
32+
- "github/codeql-action*"
33+
codeql-action-security:
34+
applies-to: security-updates
35+
patterns:
36+
- "github/codeql-action*"
2637
patch-updates:
2738
patterns:
2839
- "*"
@@ -100,6 +111,19 @@ updates:
100111
open-pull-requests-limit: 10
101112
labels:
102113
- "release-note/bump-version"
114+
# Angular majors are a migration, not a bump: the new major pins a new
115+
# TypeScript major, changes the ng-swagger-gen output and needs the wrapper
116+
# libraries (ngx-markdown, @clr/*) to follow. Keep the group on the current
117+
# major; upgrade Angular in a dedicated PR. See #23854 and #23856.
118+
ignore:
119+
- dependency-name: "@angular/*"
120+
update-types: ["version-update:semver-major"]
121+
- dependency-name: "@angular-devkit/*"
122+
update-types: ["version-update:semver-major"]
123+
- dependency-name: "@angular-eslint/*"
124+
update-types: ["version-update:semver-major"]
125+
- dependency-name: "typescript"
126+
update-types: ["version-update:semver-major"]
103127
groups:
104128
# The Angular packages pin each other with exact peer dependencies, and
105129
# @angular-devkit/build-angular and @angular/core pin typescript and
@@ -133,6 +157,19 @@ updates:
133157
open-pull-requests-limit: 10
134158
labels:
135159
- "release-note/bump-version"
160+
# Angular majors are a migration, not a bump: the new major pins a new
161+
# TypeScript major, changes the ng-swagger-gen output and needs the wrapper
162+
# libraries (ngx-markdown, @clr/*) to follow. Keep the group on the current
163+
# major; upgrade Angular in a dedicated PR. See #23854 and #23856.
164+
ignore:
165+
- dependency-name: "@angular/*"
166+
update-types: ["version-update:semver-major"]
167+
- dependency-name: "@angular-devkit/*"
168+
update-types: ["version-update:semver-major"]
169+
- dependency-name: "@angular-eslint/*"
170+
update-types: ["version-update:semver-major"]
171+
- dependency-name: "typescript"
172+
update-types: ["version-update:semver-major"]
136173
groups:
137174
angular:
138175
patterns:

.github/workflows/codeql-analysis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030

3131
# Initializes the CodeQL tools for scanning.
3232
- name: Initialize CodeQL
33-
uses: github/codeql-action/init@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
33+
uses: github/codeql-action/init@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
3434
# Override language selection by uncommenting this and choosing your languages
3535
# with:
3636
# languages: go, javascript, csharp, python, cpp, java
@@ -55,4 +55,4 @@ jobs:
5555
# https://github.com/github/codeql/issues/15647#issuecomment-2003768106
5656

5757
- name: Perform CodeQL Analysis
58-
uses: github/codeql-action/analyze@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
58+
uses: github/codeql-action/analyze@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0

.github/workflows/nightly-trivy-scan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ jobs:
3737
# Ref: https://github.com/aquasecurity/trivy-action/issues/389
3838
TRIVY_DB_REPOSITORY: 'public.ecr.aws/aquasecurity/trivy-db:2'
3939
- name: Upload Trivy scan results to GitHub Security tab
40-
uses: github/codeql-action/upload-sarif@cdf488f595d80d6e07e03d4674febd5ab45fa938 # v4.37.9
40+
uses: github/codeql-action/upload-sarif@b96794f015dfd88f77b49b1c93e0fa7110f94c63 # v4.38.0
4141
with:
4242
sarif_file: 'trivy-results.sarif'

make/migrations/postgresql/0190_2.16.0_schema.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ ALTER TABLE robot ALTER COLUMN creator_ref TYPE bigint;
1717
ALTER TABLE role_permission ALTER COLUMN role_id TYPE bigint;
1818
ALTER SEQUENCE robot_id_seq AS bigint MAXVALUE 9007199254740991;
1919

20-
CREATE INDEX idx_sbom_report_sbom_digest
20+
CREATE INDEX IF NOT EXISTS idx_sbom_report_sbom_digest
2121
ON sbom_report (mime_type, ((report::jsonb ->> 'sbom_digest')));

src/cmd/exporter/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package main
1616

1717
import (
18+
"errors"
1819
"net/http"
1920
"os"
2021
"strings"
@@ -99,7 +100,7 @@ func main() {
99100
exporterOpt.CacheCleanInterval,
100101
)
101102
prometheus.MustRegister(harborExporter)
102-
if err := harborExporter.ListenAndServe(); err != nil {
103+
if err := harborExporter.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
103104
log.Errorf("Error starting Harbor exporter %s", err)
104105
os.Exit(1)
105106
}

src/common/dao/testutils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func PrepareTestForPostgresSQL() {
7070
},
7171
}
7272

73-
log.Infof("POSTGRES_HOST: %s, POSTGRES_USR: %s, POSTGRES_PORT: %d, POSTGRES_PWD: %s\n", dbHost, dbUser, dbPort, dbPassword)
73+
log.Infof("POSTGRES_HOST: %s, POSTGRES_USR: %s, POSTGRES_PORT: %d\n", dbHost, dbUser, dbPort)
7474
o = initDatabaseForTest(database)
7575
}
7676

src/common/security/secret/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (s *SecurityContext) IsAuthenticated() bool {
4949
}
5050
valid := s.store.IsValid(s.secret)
5151
if !valid {
52-
log.Debugf("invalid secret: %s", s.secret)
52+
log.Debug("invalid secret")
5353
}
5454

5555
return valid

src/common/utils/test/database.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func InitDatabaseFromEnv() {
6363
},
6464
}
6565

66-
log.Infof("POSTGRES_HOST: %s, POSTGRES_USR: %s, POSTGRES_PORT: %d, POSTGRES_PWD: %s\n", dbHost, dbUser, dbPort, dbPassword)
66+
log.Infof("POSTGRES_HOST: %s, POSTGRES_USR: %s, POSTGRES_PORT: %d\n", dbHost, dbUser, dbPort)
6767

6868
if err := dao.InitDatabase(database); err != nil {
6969
log.Fatalf("failed to init database : %v", err)

src/common/utils/utils.go

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,26 @@ func ParseEndpoint(endpoint string) (*url.URL, error) {
5151
endpoint = "http://" + endpoint
5252
}
5353

54-
return url.ParseRequestURI(endpoint)
54+
u, err := url.ParseRequestURI(endpoint)
55+
if err == nil && u != nil {
56+
u.Host = strings.ToLower(u.Host)
57+
}
58+
return u, err
59+
}
60+
61+
// EqualURL checks whether two URLs are equal, with case-insensitive host matching per RFC 1035.
62+
func EqualURL(rawURL1, rawURL2 string) bool {
63+
if rawURL1 == rawURL2 {
64+
return true
65+
}
66+
u1, err1 := url.Parse(rawURL1)
67+
u2, err2 := url.Parse(rawURL2)
68+
if err1 != nil || err2 != nil {
69+
return false
70+
}
71+
u1.Host = strings.ToLower(u1.Host)
72+
u2.Host = strings.ToLower(u2.Host)
73+
return u1.String() == u2.String()
5574
}
5675

5776
// ParseRepository splits a repository into two parts: project and rest
@@ -66,19 +85,33 @@ func ParseRepository(repository string) (project, rest string) {
6685
return
6786
}
6887

69-
// GenerateRandomStringWithLen generates a random string with length
70-
func GenerateRandomStringWithLen(length int) string {
88+
// GenerateRandomStringWithLenAndError generates a random string with length or returns an error if entropy cannot be read
89+
func GenerateRandomStringWithLenAndError(length int) (string, error) {
7190
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
7291
l := len(chars)
7392
result := make([]byte, length)
7493
_, err := rand.Read(result)
7594
if err != nil {
76-
log.Warningf("Error reading random bytes: %v", err)
95+
return "", fmt.Errorf("failed to read random bytes: %w", err)
7796
}
7897
for i := range length {
7998
result[i] = chars[int(result[i])%l]
8099
}
81-
return string(result)
100+
return string(result), nil
101+
}
102+
103+
// GenerateRandomStringOrError generates a random string with 32 byte length or returns an error if entropy cannot be read
104+
func GenerateRandomStringOrError() (string, error) {
105+
return GenerateRandomStringWithLenAndError(32)
106+
}
107+
108+
// GenerateRandomStringWithLen generates a random string with length
109+
func GenerateRandomStringWithLen(length int) string {
110+
str, err := GenerateRandomStringWithLenAndError(length)
111+
if err != nil {
112+
log.Warningf("Error reading random bytes: %v", err)
113+
}
114+
return str
82115
}
83116

84117
// GenerateRandomString generate a random string with 32 byte length

src/common/utils/utils_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ func TestParseEndpoint(t *testing.T) {
3737
{"ftp://example.com", true, ""},
3838
{"http://example.com", false, "http://example.com"},
3939
{"https://example.com", false, "https://example.com"},
40+
{"http://EXAMPLE.COM", false, "http://example.com"},
41+
{"https://EXAMPLE.COM:8080/Path", false, "https://example.com:8080/Path"},
42+
{" MIXED.case.com/path/ ", false, "http://mixed.case.com/path"},
4043
{"http://example!@#!?//#", true, ""},
4144
}
4245

@@ -51,6 +54,31 @@ func TestParseEndpoint(t *testing.T) {
5154
}
5255
}
5356

57+
func TestEqualURL(t *testing.T) {
58+
cases := []struct {
59+
url1 string
60+
url2 string
61+
expected bool
62+
}{
63+
{"http://example.com:8080/v2", "http://example.com:8080/v2", true},
64+
{"http://EXAMPLE.COM:8080/v2", "http://example.com:8080/v2", true},
65+
{"http://example.com:8080/V2", "http://example.com:8080/v2", false},
66+
{"https://core:8080", "https://CORE:8080", true},
67+
{"http://example.com", "https://example.com", false},
68+
{"http://example.com:8080", "http://example.com:8081", false},
69+
{"http://example.com/foo", "http://example.com/bar", false},
70+
{"://invalid-url-1", "http://example.com", false},
71+
{"http://example.com", "://invalid-url-2", false},
72+
{"http://example.com/A%", "http://example.com/a%", false},
73+
}
74+
75+
for _, c := range cases {
76+
t.Run(c.url1+"_vs_"+c.url2, func(t *testing.T) {
77+
assert.Equal(t, c.expected, EqualURL(c.url1, c.url2))
78+
})
79+
}
80+
}
81+
5482
func TestParseRepository(t *testing.T) {
5583
repository := "library/ubuntu"
5684
project, rest := ParseRepository(repository)
@@ -155,13 +183,28 @@ func TestGenerateRandomString(t *testing.T) {
155183
}
156184
}
157185

186+
func TestGenerateRandomStringOrError(t *testing.T) {
187+
str, err := GenerateRandomStringOrError()
188+
assert.Nil(t, err)
189+
assert.Equal(t, 32, len(str))
190+
str2, err := GenerateRandomStringOrError()
191+
assert.Nil(t, err)
192+
assert.NotEqual(t, str, str2)
193+
}
194+
158195
func TestGenerateRandomStringWithLen(t *testing.T) {
159196
str := GenerateRandomStringWithLen(16)
160197
if len(str) != 16 {
161198
t.Errorf("Failed to generate ramdom string with fixed length.")
162199
}
163200
}
164201

202+
func TestGenerateRandomStringWithLenAndError(t *testing.T) {
203+
str, err := GenerateRandomStringWithLenAndError(16)
204+
assert.Nil(t, err)
205+
assert.Equal(t, 16, len(str))
206+
}
207+
165208
func TestTestTCPConn(t *testing.T) {
166209
server := httptest.NewServer(nil)
167210
defer server.Close()

0 commit comments

Comments
 (0)