Skip to content

Commit a227169

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 a227169

File tree

2 files changed

+28
-16
lines changed

2 files changed

+28
-16
lines changed

flux/src/helm-releases/Inventory.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,16 @@ 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
278+
? 'toolkit'
279+
: groupName.substring(0, groupName.indexOf('.'));
280+
275281
return (
276282
<Link
277-
routeName={groupName.substring(0, groupName.indexOf('.'))}
283+
routeName={routeName}
278284
params={{
279285
pluralName: pluralName,
280286
name: item.metadata.name,

flux/src/kustomizations/Inventory.tsx

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

133133
// Flux types
134-
if (groupName.endsWith('toolkit.fluxcd.io')) {
135-
return (
136-
<Link
137-
routeName={groupName.substr(0, groupName.indexOf('.'))}
138-
params={{
139-
pluralName: pluralName,
140-
name: item.metadata.name,
141-
namespace: item.metadata.namespace,
142-
}}
143-
>
144-
{item.metadata.name}
145-
</Link>
146-
);
147-
}
134+
const allowedDomain = 'toolkit.fluxcd.io';
135+
if (groupName === allowedDomain || groupName.endswith(`.${allowedDomain}`)) {
136+
const routeName =
137+
groupName === allowedDomain
138+
? 'toolkit'
139+
: groupName.substring(0, groupName.indexOf('.'));
140+
141+
return (
142+
<Link
143+
routeName={routeName}
144+
params={{
145+
pluralName: pluralName,
146+
name: item.metadata.name,
147+
namespace: item.metadata.namespace,
148+
}}
149+
>
150+
{item.metadata.name}
151+
</Link>
152+
);
153+
}
148154

149155
// standard k8s types
150156
const resourceKind = K8s.ResourceClasses[kind];

0 commit comments

Comments
 (0)