Skip to content

Commit

Permalink
fix: validate snippet filenames before reading & increase error verbo…
Browse files Browse the repository at this point in the history
…sity

fixes #443
  • Loading branch information
jankal committed Nov 27, 2024
1 parent 9e5a40d commit 26b99a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/project/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ func cleanupAdministrationFiles(ctx context.Context, folder string) error {

languageName := strings.TrimSuffix(filepath.Base(path), fileExt)

if _, err := language.Parse(languageName); err != nil {
logging.FromContext(ctx).Infof("Ignoring invalid locale filename %s", path)
return nil

Check failure on line 353 in cmd/project/ci.go

View workflow job for this annotation

GitHub Actions / lint

error is not nil (line 351) but it returns nil (nilerr)
}

if language.Make(languageName).IsRoot() {
return nil
}
Expand Down Expand Up @@ -389,7 +394,7 @@ func cleanupAdministrationFiles(ctx context.Context, folder string) error {
}

if err := json.Unmarshal(data, &snippetFile); err != nil {
return err
return fmt.Errorf("unable to parse %s: %w", file, err)
}

if err := mergo.Merge(&merged, snippetFile, mergo.WithOverride); err != nil {
Expand Down

0 comments on commit 26b99a5

Please sign in to comment.