Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions web/cypress/e2e/monitoring/00.bvt_admin.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ describe('BVT: Monitoring', { tags: ['@smoke', '@monitoring'] }, () => {
});

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
//TODO: remove this double Metrics click after the issue is fixed
nav.sidenav.clickNavLink(['Observe', 'Metrics']);
commonPages.titleShouldHaveText('Metrics');
cy.changeNamespace('All Projects');
Expand All @@ -36,6 +38,8 @@ describe('BVT: Monitoring', { tags: ['@smoke', '@monitoring'] }, () => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
commonPages.titleShouldHaveText('Dashboards');
nav.sidenav.clickNavLink(['Observe', 'Targets']);
//TODO: remove this double Targets click after the issue is fixed
nav.sidenav.clickNavLink(['Observe', 'Targets']);
commonPages.titleShouldHaveText('Metrics targets');
});
// TODO: Intercept Bell GET request to inject an alert (Watchdog to have it opened in
Expand Down
1 change: 1 addition & 0 deletions web/cypress/e2e/perses/00.coo_bvt_perses_admin.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.changeNamespace('All Projects');
});

//TODO: rename after customizable-dashboards gets merged
Expand Down
1 change: 1 addition & 0 deletions web/cypress/e2e/perses/04.coo_import_perses_admin.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.wait(5000);
cy.changeNamespace('All Projects');
Expand Down
3 changes: 3 additions & 0 deletions web/cypress/e2e/perses/99.coo_rbac_perses_user1.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe(

// Step 2: Setup COO and Perses dashboards (requires admin privileges)
cy.beforeBlockCOO(MCP, MP, { dashboards: true, troubleshootingPanel: false });
cy.cleanupPersesTestDashboardsBeforeTests();
cy.setupPersesRBACandExtraDashboards();

//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
Expand Down Expand Up @@ -68,7 +69,9 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.changeNamespace('All Projects');
});

after(() => {
Expand Down
2 changes: 2 additions & 0 deletions web/cypress/e2e/perses/99.coo_rbac_perses_user2.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe(

// Step 2: Setup COO and Perses dashboards (requires admin privileges)
cy.beforeBlockCOO(MCP, MP, { dashboards: true, troubleshootingPanel: false });
cy.cleanupPersesTestDashboardsBeforeTests();
cy.setupPersesRBACandExtraDashboards();

//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
Expand Down Expand Up @@ -68,6 +69,7 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.changeNamespace('All Projects');
});
Expand Down
3 changes: 3 additions & 0 deletions web/cypress/e2e/perses/99.coo_rbac_perses_user3.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe(

// Step 2: Setup COO and Perses dashboards (requires admin privileges)
cy.beforeBlockCOO(MCP, MP, { dashboards: true, troubleshootingPanel: false });
cy.cleanupPersesTestDashboardsBeforeTests();
cy.setupPersesRBACandExtraDashboards();

//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
Expand Down Expand Up @@ -68,7 +69,9 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.changeNamespace('All Projects');
});

after(() => {
Expand Down
3 changes: 3 additions & 0 deletions web/cypress/e2e/perses/99.coo_rbac_perses_user4.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe(

// Step 2: Setup COO and Perses dashboards (requires admin privileges)
cy.beforeBlockCOO(MCP, MP, { dashboards: true, troubleshootingPanel: false });
cy.cleanupPersesTestDashboardsBeforeTests();
cy.setupPersesRBACandExtraDashboards();

//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
Expand Down Expand Up @@ -68,7 +69,9 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.changeNamespace('All Projects');
});

after(() => {
Expand Down
3 changes: 3 additions & 0 deletions web/cypress/e2e/perses/99.coo_rbac_perses_user5.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe(

// Step 2: Setup COO and Perses dashboards (requires admin privileges)
cy.beforeBlockCOO(MCP, MP, { dashboards: true, troubleshootingPanel: false });
cy.cleanupPersesTestDashboardsBeforeTests();
cy.setupPersesRBACandExtraDashboards();

//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
Expand Down Expand Up @@ -68,7 +69,9 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
cy.changeNamespace('All Projects');
});

after(() => {
Expand Down
2 changes: 2 additions & 0 deletions web/cypress/e2e/perses/99.coo_rbac_perses_user6.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe(

// Step 2: Setup COO and Perses dashboards (requires admin privileges)
cy.beforeBlockCOO(MCP, MP, { dashboards: true, troubleshootingPanel: false });
cy.cleanupPersesTestDashboardsBeforeTests();
cy.setupPersesRBACandExtraDashboards();

//TODO: https://issues.redhat.com/browse/OCPBUGS-58468 - when it gets fixed, installation can be don using non-admin user
Expand Down Expand Up @@ -68,6 +69,7 @@ describe(

beforeEach(() => {
nav.sidenav.clickNavLink(['Observe', 'Dashboards']);
cy.wait(2000);
nav.sidenav.clickNavLink(['Observe', 'Dashboards (Perses)']);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,31 +231,6 @@
}
]
}
},
"c03e17f849d341bcb1139c65e68dad1d": {
"kind": "Panel",
"spec": {
"display": {
"name": "status history"
},
"plugin": {
"kind": "StatusHistoryChart",
"spec": {}
},
"queries": [
{
"kind": "TimeSeriesQuery",
"spec": {
"plugin": {
"kind": "PrometheusTimeSeriesQuery",
"spec": {
"query": "vector(1)"
}
}
}
}
]
}
}
},
"layouts": [
Expand Down Expand Up @@ -317,16 +292,7 @@
{
"x": 0,
"y": 15,
"width": 12,
"height": 6,
"content": {
"$ref": "#/spec/panels/c03e17f849d341bcb1139c65e68dad1d"
}
},
{
"x": 12,
"y": 15,
"width": 12,
"width": 24,
"height": 6,
"content": {
"$ref": "#/spec/panels/31b8374866184a26beddf46ec30df0b5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,21 +143,6 @@ spec:
kind: PrometheusTimeSeriesQuery
spec:
query: up
c03e17f849d341bcb1139c65e68dad1d:
kind: Panel
spec:
display:
name: status history
plugin:
kind: StatusHistoryChart
spec: {}
queries:
- kind: TimeSeriesQuery
spec:
plugin:
kind: PrometheusTimeSeriesQuery
spec:
query: vector(1)
layouts:
- kind: Grid
spec:
Expand Down Expand Up @@ -198,13 +183,7 @@ spec:
$ref: "#/spec/panels/57ce686052c9464fa9486ff49d3757cd"
- x: 0
"y": 15
width: 12
height: 6
content:
$ref: "#/spec/panels/c03e17f849d341bcb1139c65e68dad1d"
- x: 12
"y": 15
width: 12
width: 24
height: 6
content:
$ref: "#/spec/panels/31b8374866184a26beddf46ec30df0b5"
Expand Down
15 changes: 8 additions & 7 deletions web/cypress/fixtures/perses/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ export const persesDashboardsAddPanelAddQueryType = {
};

export const persesCreateDashboard = {
DIALOG_MAX_LENGTH_VALIDATION: 'Must be 75 or fewer characters long: error status;',
DIALOG_MAX_LENGTH_VALIDATION:
'Danger alert:bad request: code=400, message=cannot contain more than 75 characters, internal=cannot contain more than 75 characters',
DIALOG_DUPLICATED_NAME_PF_VALIDATION_PREFIX: 'Dashboard name ',
DIALOG_DUPLICATED_NAME_PF_VALIDATION_SUFFIX: ' already exists in ',
DIALOG_DUPLICATED_NAME_PF_VALIDATION_SUFFIX_PROJECT: ' project!: error status;',
DIALOG_DUPLICATED_NAME_BKD_VALIDATION:
'Danger alert:Could not create dashboard. e: document already exists',
DIALOG_CREATE_NAME_BKD_VALIDATION: 'Danger alert:document already exists',
};

export const persesDashboardsEmptyDashboard = {
Expand All @@ -167,7 +167,9 @@ export const persesDashboardsRenameDashboard = {
};

export const persesDashboardsDuplicateDashboard = {
DIALOG_DUPLICATED_NAME_VALIDATION: 'already exists', //use contains
DIALOG_DUPLICATED_NAME_VALIDATION: 'Could not duplicate dashboard. e: document already exists', //use contains
DIALOG_DUPLICATED_NAME_FED_VALIDATION_1: 'Dashboard name "',
DIALOG_DUPLICATED_NAME_FED_VALIDATION_2: '" already exists in this project: error status;',
};

export const persesDashboardsImportDashboard = {
Expand All @@ -180,7 +182,6 @@ export const persesDashboardsImportDashboard = {
'Grafana dashboard detected. It will be automatically migrated to Perses format. Note: migration may be partial as not all Grafana features are supported.',
DIALOG_PERSES_DASHBOARD_DETECTED: 'Perses dashboard detected.',
DIALOG_FAILED_TO_MIGRATE_GRAFANA_DASHBOARD:
'Danger alert:Error migrating dashboard: Failed to migrate dashboard: internal server error',
DIALOG_DUPLICATED_DASHBOARD_ERROR:
'Danger alert:Error importing dashboard: document already exists',
'Danger alert:Failed to migrate dashboard: internal server error',
DIALOG_DUPLICATED_DASHBOARD_ERROR: 'Danger alert:document already exists',
};
113 changes: 33 additions & 80 deletions web/cypress/support/commands/dashboards-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,92 +30,45 @@ export const dashboardsUtils = {
failOnNonZeroExit: false,
});

/**
* TODO: When COO1.4.0 is released, points COO_UI_INSTALL to install dashboards on
* COO1.4.0 folder
*/
if (Cypress.env('COO_UI_INSTALL')) {
cy.log('COO_UI_INSTALL is set. Installing dashboards on COO1.4.0 folder');

cy.log('Create openshift-cluster-sample-dashboard instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`openshift-cluster-sample-dashboard.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create perses-dashboard-sample instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`perses-dashboard-sample.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create prometheus-overview-variables instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`prometheus-overview-variables.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create thanos-compact-overview-1var instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`thanos-compact-overview-1var.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create Thanos Querier instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`thanos-querier-datasource.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
} else {
cy.log('COO_UI_INSTALL is not set. Installing dashboards on COO1.4.0 folder');

cy.log('Create openshift-cluster-sample-dashboard instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`openshift-cluster-sample-dashboard.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
cy.log('Create openshift-cluster-sample-dashboard instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`openshift-cluster-sample-dashboard.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create perses-dashboard-sample instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`perses-dashboard-sample.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
cy.log('Create perses-dashboard-sample instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`perses-dashboard-sample.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create prometheus-overview-variables instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`prometheus-overview-variables.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
cy.log('Create prometheus-overview-variables instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`prometheus-overview-variables.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create thanos-compact-overview-1var instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`thanos-compact-overview-1var.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
cy.log('Create thanos-compact-overview-1var instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`thanos-compact-overview-1var.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

cy.log('Create Thanos Querier instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`thanos-querier-datasource.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
}
cy.log('Create Thanos Querier instance.');
cy.exec(
`oc apply -f ./cypress/fixtures/coo/coo140_perses/dashboards/` +
`thanos-querier-datasource.yaml ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);
Comment on lines +34 to +66
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the file to see the actual code
head -100 web/cypress/support/commands/dashboards-commands.ts | tail -n +1 | cat -n

Repository: openshift/monitoring-plugin

Length of output: 4301


🏁 Script executed:

# Let's get the full context around the lines in question
sed -n '1,100p' web/cypress/support/commands/dashboards-commands.ts | cat -n

Repository: openshift/monitoring-plugin

Length of output: 4301


🏁 Script executed:

# Search for all uses of KUBECONFIG_PATH in the codebase
rg 'KUBECONFIG_PATH' --type ts --type js -n

Repository: openshift/monitoring-plugin

Length of output: 11844


🏁 Script executed:

# Search for all cy.exec calls to understand the pattern
rg 'cy\.exec\(' web/cypress --type ts --type js -A 3 | head -100

Repository: openshift/monitoring-plugin

Length of output: 8006


🏁 Script executed:

# Look for any helper functions that might be handling environment variables safely
rg 'function|const.*=.*\(' web/cypress/support/commands/dashboards-commands.ts -n | cat -n

Repository: openshift/monitoring-plugin

Length of output: 267


Quote the KUBECONFIG_PATH environment variable before passing it to cy.exec.

The five oc apply calls at lines 34–66 interpolate Cypress.env('KUBECONFIG_PATH') unquoted into shell commands. A path with spaces will cause the command to fail, and a tainted env value can inject shell tokens. Wrap the value in quotes: --kubeconfig "${Cypress.env('KUBECONFIG_PATH')}", or extract it to a variable and pass via the env option instead.

🧰 Tools
🪛 OpenGrep (1.20.0)

[ERROR] 34-38: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)


[ERROR] 41-45: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)


[ERROR] 48-52: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)


[ERROR] 55-59: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)


[ERROR] 62-66: Dynamic command passed to child_process.exec/execSync. Use child_process.execFile or spawn with an argument array instead.

(coderabbit.command-injection.exec-js)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/cypress/support/commands/dashboards-commands.ts` around lines 34 - 66,
The cy.exec calls that build the oc apply commands interpolate
Cypress.env('KUBECONFIG_PATH') directly which breaks for paths with spaces or
malicious values; update each cy.exec string construction (the oc apply
invocations) to quote the kubeconfig value (e.g. --kubeconfig
"${Cypress.env('KUBECONFIG_PATH')}") or alternatively read const kube =
Cypress.env('KUBECONFIG_PATH') and pass it safely via the cy.exec env option,
ensuring every cy.exec invocation that references Cypress.env('KUBECONFIG_PATH')
is updated.


cy.exec(
`oc label namespace ${
MCP.namespace
} openshift.io/cluster-monitoring=true --overwrite=true --kubeconfig ${Cypress.env(
'KUBECONFIG_PATH',
)}`,
`oc label namespace ${MCP.namespace} ` +
`openshift.io/cluster-monitoring=true --overwrite=true ` +
`--kubeconfig ${Cypress.env('KUBECONFIG_PATH')}`,
);

waitForPodsReady(
Expand Down
Loading