Skip to content

Commit fc3d9da

Browse files
committed
flux: Sanitize domain URL for validation
These changes to the flux source code replace the endsWith check with a more precise validation that ensures the groupName is either toolkit.fluxcd.io or a valid subdomain of it. Signed-off-by: Evangelos Skopelitis <[email protected]>
1 parent 6d20135 commit fc3d9da

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

flux/src/helm-releases/Inventory.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,14 @@ function inventoryNameLink(item): JSX.Element {
271271
const pluralName = PluralName(kind);
272272

273273
// Flux types
274-
if (groupName.endsWith('toolkit.fluxcd.io')) {
274+
const allowedDomain = 'toolkit.fluxcd.io';
275+
if (groupName === allowedDomain || groupName.endswith(`.${allowedDomain}`)) {
276+
const routeName =
277+
groupName === allowedDomain ? 'toolkit' : groupName.substring(0, groupName.indexOf('.'));
278+
275279
return (
276280
<Link
277-
routeName={groupName.substring(0, groupName.indexOf('.'))}
281+
routeName={routeName}
278282
params={{
279283
pluralName: pluralName,
280284
name: item.metadata.name,

flux/src/kustomizations/Inventory.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,14 @@ function inventoryNameLink(item: KubeObject) {
131131
const pluralName = PluralName(kind);
132132

133133
// Flux types
134-
if (groupName.endsWith('toolkit.fluxcd.io')) {
134+
const allowedDomain = 'toolkit.fluxcd.io';
135+
if (groupName === allowedDomain || groupName.endswith(`.${allowedDomain}`)) {
136+
const routeName =
137+
groupName === allowedDomain ? 'toolkit' : groupName.substring(0, groupName.indexOf('.'));
138+
135139
return (
136140
<Link
137-
routeName={groupName.substr(0, groupName.indexOf('.'))}
141+
routeName={routeName}
138142
params={{
139143
pluralName: pluralName,
140144
name: item.metadata.name,

0 commit comments

Comments
 (0)