Files
kubevela/pkg/addon
Anas Khan 6fd0e71e50 Fix: prevent panics in ParseGitlab on malformed addon registry URLs (#7206)
ParseGitlab indexed the results of splitting the address without bounds
checks, so a malformed (but repo-name-matching) GitLab registry URL crashed
the controller/CLI instead of returning an error. Three inputs panic today:

  - https://gitlab.com/catalog          -> slice bounds out of range [:-1]
  - https://gitlab.com/kubevela/catalog/tree -> index out of range [2]
  - https://catalog.gitlab.com/kubevela/foo  -> index out of range [1]

Add length/empty guards that return the existing invalid-format error
(errInvalidFormatMsg, consistent with Parse) for the empty owner slice, the
short host split, and the missing tree branch segment. Behaviour for all
currently-valid inputs is unchanged.

Also fix the caller NewAsyncReader, which dereferenced the returned content
before checking the error: on any ParseGitlab error content is nil, so the
assignment nil-panicked before the error could be returned. Move the error
check above the dereference.

Extend TestParseGitlab with the three malformed cases (wantErr).

Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
2026-07-15 11:16:48 +01:00
..
2026-02-10 15:00:44 +00:00
2026-02-10 15:00:44 +00:00
2026-02-10 15:00:44 +00:00
2026-02-10 15:00:44 +00:00
2026-02-10 15:00:44 +00:00