Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RsponseOps][Alerting] Explicitly set access to all API routes of actions, connectors, rules, alerts, and cases plugins #193520

Merged
merged 9 commits into from
Sep 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const getAllConnectorsIncludingSystemRoute = (
{
path: `${INTERNAL_BASE_ACTION_API_PATH}/connectors`,
validate: {},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const listTypesWithSystemRoute = (
validate: {
query: connectorTypesQuerySchemaV1,
},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const getGlobalExecutionKPIRoute = (
validate: {
body: bodySchema,
},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export const getGlobalExecutionLogRoute = (
validate: {
body: bodySchema,
},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export const getOAuthAccessToken = (
validate: {
body: bodySchema,
},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export const deleteBackfillRoute = (
router.delete(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rules/backfill/{id}`,
options: {
access: 'internal',
},
validate: {
params: deleteParamsSchemaV1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const findBackfillRoute = (
validate: {
query: findQuerySchemaV1,
},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export const getBackfillRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rules/backfill/{id}`,
options: {
access: 'internal',
},
validate: {
params: getParamsSchemaV1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const scheduleBackfillRoute = (
router.post(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rules/backfill/_schedule`,
options: { access: 'internal' },
validate: {
body: scheduleBodySchemaV1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const getActionErrorLogRoute = (
params: paramSchema,
query: querySchema,
},
options: {
access: 'internal',
},
},
router.handleLegacyErrors(
verifyAccessAndContext(licenseState, async function (context, req, res) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('getFlappingSettingsRoute', () => {
expect(config).toMatchInlineSnapshot(`
Object {
"options": Object {
"access": "internal",
"tags": Array [
"access:read-flapping-settings",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const getFlappingSettingsRoute = (
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rules/settings/_flapping`,
validate: false,
options: {
access: 'internal',
tags: [`access:${API_PRIVILEGES.READ_FLAPPING_SETTINGS}`],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ export const getGlobalExecutionKPIRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/_global_execution_kpi`,
options: {
access: 'internal',
},
validate: {
query: querySchema,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ export const getGlobalExecutionLogRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/_global_execution_logs`,
options: {
access: 'internal',
},
validate: {
query: querySchema,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ export const getRuleAlertSummaryRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rule/{id}/_alert_summary`,
options: {
access: 'internal',
},
validate: {
params: paramSchema,
query: querySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const getRuleExecutionKPIRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rule/{id}/_execution_kpi`,
options: {
access: 'internal',
},
validate: {
params: paramSchema,
query: querySchema,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export const getRuleExecutionLogRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rule/{id}/_execution_log`,
options: {
access: 'internal',
},
validate: {
params: paramSchema,
query: querySchema,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/alerting/server/routes/get_rule_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const getRuleStateRoute = (
router.get(
{
path: `${INTERNAL_BASE_ALERTING_API_PATH}/rule/{id}/state`,
options: {
access: 'internal',
},
validate: {
params: paramSchema,
},
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const createAlertRoute = ({ router, licenseState, usageCounter }: RouteOp
body: bodySchema,
},
options: {
access: 'public',
summary: 'Create an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const deleteAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Delete an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const disableAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Disable an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/enable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const enableAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Enable an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const findAlertRoute = (
query: querySchema,
},
options: {
access: 'public',
summary: 'Find alerts',
tags: ['oas-tag:alerting'],
description:
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const getAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Get an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const getAlertInstanceSummaryRoute = (
query: querySchema,
},
options: {
access: 'public',
summary: 'Get an alert summary',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const getAlertStateRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Get the state of an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/health.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export function healthRoute(
path: '/api/alerts/_health',
validate: false,
options: {
access: 'public',
summary: 'Get the alerting framework health',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const listAlertTypesRoute = (
path: `${LEGACY_BASE_ALERT_API_PATH}/list_alert_types`,
validate: {},
options: {
access: 'public',
summary: 'Get the alert types',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/mute_all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const muteAllAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Mute all alert instances',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const muteAlertInstanceRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Mute an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const unmuteAllAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Unmute all alert instances',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const unmuteAlertInstanceRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Unmute an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/alerting/server/routes/legacy/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const updateAlertRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Update an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const updateApiKeyRoute = (
params: paramSchema,
},
options: {
access: 'public',
summary: 'Update the API key for an alert',
tags: ['oas-tag:alerting'],
deprecated: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ describe('archiveMaintenanceWindowRoute', () => {
);

expect(config.path).toEqual('/internal/alerting/rules/maintenance_window/{id}/_archive');
expect(config.options?.tags?.[0]).toEqual('access:write-maintenance-window');
expect(config.options).toMatchInlineSnapshot(`
Object {
"access": "internal",
"tags": Array [
"access:write-maintenance-window",
],
}
`);

await handler(context, req, res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const archiveMaintenanceWindowRoute = (
body: archiveBodySchemaV1,
},
options: {
access: 'internal',
tags: [`access:${MAINTENANCE_WINDOW_API_PRIVILEGES.WRITE_MAINTENANCE_WINDOW}`],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ describe('bulkGetMaintenanceWindowRoute', () => {
);

expect(config.path).toEqual('/internal/alerting/rules/maintenance_window/_bulk_get');
expect(config.options?.tags?.[0]).toEqual('access:read-maintenance-window');
expect(config.options).toMatchInlineSnapshot(`
Object {
"access": "internal",
"tags": Array [
"access:read-maintenance-window",
],
}
`);

await handler(context, req, res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const bulkGetMaintenanceWindowRoute = (
body: bulkGetBodySchemaV1,
},
options: {
access: 'internal',
tags: [`access:${MAINTENANCE_WINDOW_API_PRIVILEGES.READ_MAINTENANCE_WINDOW}`],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ describe('createMaintenanceWindowRoute', () => {
);

expect(config.path).toEqual('/internal/alerting/rules/maintenance_window');
expect(config.options?.tags?.[0]).toEqual('access:write-maintenance-window');
expect(config.options).toMatchInlineSnapshot(`
Object {
"access": "internal",
"tags": Array [
"access:write-maintenance-window",
],
}
`);

await handler(context, req, res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const createMaintenanceWindowRoute = (
body: createBodySchemaV1,
},
options: {
access: 'internal',
tags: [`access:${MAINTENANCE_WINDOW_API_PRIVILEGES.WRITE_MAINTENANCE_WINDOW}`],
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ describe('deleteMaintenanceWindowRoute', () => {
);

expect(config.path).toEqual('/internal/alerting/rules/maintenance_window/{id}');
expect(config.options?.tags?.[0]).toEqual('access:write-maintenance-window');
expect(config.options).toMatchInlineSnapshot(`
Object {
"access": "internal",
"tags": Array [
"access:write-maintenance-window",
],
}
`);

await handler(context, req, res);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const deleteMaintenanceWindowRoute = (
params: deleteParamsSchemaV1,
},
options: {
access: 'internal',
tags: [`access:${MAINTENANCE_WINDOW_API_PRIVILEGES.WRITE_MAINTENANCE_WINDOW}`],
},
},
Expand Down
Loading