Skip to content

Commit a7ae238

Browse files
committed
[SP-2882] chore: enhancements
1 parent 7901638 commit a7ae238

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ env:
1313
ARTIFACT_NAME_PREFIX: "SCANOSS Code Compare"
1414
ARTIFACT_NAME_PREFIX_WINDOWS: "scanoss-cc"
1515
GOLANG_VERSION: "1.23"
16-
NODE_VERSION: "16.x"
16+
NODE_VERSION: "20.x"
1717

1818
jobs:
1919
build_mac:

backend/service/license_service_impl.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,13 @@
2424
package service
2525

2626
import (
27+
"fmt"
2728
"sort"
2829

30+
"github.com/rs/zerolog/log"
2931
"github.com/scanoss/scanoss.cc/backend/entities"
3032
"github.com/scanoss/scanoss.cc/backend/repository"
33+
"github.com/scanoss/scanoss.cc/internal/utils"
3134
)
3235

3336
type LicenseServiceImpl struct {
@@ -56,5 +59,9 @@ func (s *LicenseServiceImpl) GetAll() ([]entities.License, error) {
5659
}
5760

5861
func (s *LicenseServiceImpl) GetLicensesByPurl(request entities.ComponentRequest) (entities.GetLicensesByPurlResponse, error) {
62+
if err := utils.GetValidator().Struct(request); err != nil {
63+
log.Error().Err(err).Msg("Invalid component request: validation failed")
64+
return entities.GetLicensesByPurlResponse{}, fmt.Errorf("invalid component request: %w", err)
65+
}
5966
return s.scanossApiService.GetLicensesByPurl(request)
6067
}

frontend/src/components/ReplaceComponentDialog.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,14 @@ export default function ReplaceComponentDialog({ onOpenChange, onReplaceComponen
135135
};
136136

137137
const getMatchedLicenses = async (purl: string) => {
138+
setMatchedLicenses([]);
138139
try {
139140
const { component } = await GetLicensesByPurl({ purl });
140141

141-
if (!component || !component.licenses) return;
142+
if (!component || !component.licenses) {
143+
setMatchedLicenses([]);
144+
return;
145+
}
142146

143147
const matchedLicenses: entities.License[] = component.licenses.map((license) => ({
144148
name: license.full_name,
@@ -147,6 +151,7 @@ export default function ReplaceComponentDialog({ onOpenChange, onReplaceComponen
147151
}));
148152
setMatchedLicenses(matchedLicenses);
149153
} catch (error) {
154+
setMatchedLicenses([]);
150155
toast({
151156
title: 'Error',
152157
description: 'Error fetching matched licenses',

0 commit comments

Comments
 (0)