-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48d897e
commit 02d335a
Showing
20 changed files
with
230 additions
and
60 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.csp_options.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CSP\_OPTIONS](./kibana-plugin-server.csp_options.md) | ||
|
||
## CSP\_OPTIONS variable | ||
|
||
The default set of CSP options used for Kibana. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
CSP_OPTIONS: Readonly<CspOptions> | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.cspoptions.directives.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CspOptions](./kibana-plugin-server.cspoptions.md) > [directives](./kibana-plugin-server.cspoptions.directives.md) | ||
|
||
## CspOptions.directives property | ||
|
||
The CSP rules in a formatted directives string for use in a Content-Security-Policy header | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
directives: string; | ||
``` |
23 changes: 23 additions & 0 deletions
23
docs/development/core/server/kibana-plugin-server.cspoptions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CspOptions](./kibana-plugin-server.cspoptions.md) | ||
|
||
## CspOptions interface | ||
|
||
The CSP options used for Kibana. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export interface CspOptions | ||
``` | ||
|
||
## Properties | ||
|
||
| Property | Type | Description | | ||
| --- | --- | --- | | ||
| [directives](./kibana-plugin-server.cspoptions.directives.md) | <code>string</code> | The CSP rules in a formatted directives string for use in a Content-Security-Policy header | | ||
| [rules](./kibana-plugin-server.cspoptions.rules.md) | <code>string[]</code> | The CSP rules used for Kibana. | | ||
| [strict](./kibana-plugin-server.cspoptions.strict.md) | <code>boolean</code> | Specify whether browsers that do not support CSP should be able to use Kibana. Use <code>true</code> to block and <code>false</code> to allow. | | ||
| [warnLegacyBrowsers](./kibana-plugin-server.cspoptions.warnlegacybrowsers.md) | <code>boolean</code> | Specify whether users with legacy browsers should be warned about their lack of Kibana security compliance. | | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.cspoptions.rules.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CspOptions](./kibana-plugin-server.cspoptions.md) > [rules](./kibana-plugin-server.cspoptions.rules.md) | ||
|
||
## CspOptions.rules property | ||
|
||
The CSP rules used for Kibana. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
rules: string[]; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.cspoptions.strict.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CspOptions](./kibana-plugin-server.cspoptions.md) > [strict](./kibana-plugin-server.cspoptions.strict.md) | ||
|
||
## CspOptions.strict property | ||
|
||
Specify whether browsers that do not support CSP should be able to use Kibana. Use `true` to block and `false` to allow. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
strict: boolean; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/server/kibana-plugin-server.cspoptions.warnlegacybrowsers.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [CspOptions](./kibana-plugin-server.cspoptions.md) > [warnLegacyBrowsers](./kibana-plugin-server.cspoptions.warnlegacybrowsers.md) | ||
|
||
## CspOptions.warnLegacyBrowsers property | ||
|
||
Specify whether users with legacy browsers should be warned about their lack of Kibana security compliance. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
warnLegacyBrowsers: boolean; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import { TypeOf, schema } from '@kbn/config-schema'; | ||
|
||
/** | ||
* The CSP options used for Kibana. | ||
* @public | ||
*/ | ||
export interface CspOptions { | ||
/** | ||
* The CSP rules in a formatted directives string for use | ||
* in a `Content-Security-Policy` header. | ||
*/ | ||
directives: string; | ||
|
||
/** | ||
* The CSP rules used for Kibana. | ||
*/ | ||
rules: string[]; | ||
|
||
/** | ||
* Specify whether browsers that do not support CSP should be | ||
* able to use Kibana. Use `true` to block and `false` to allow. | ||
*/ | ||
strict: boolean; | ||
|
||
/** | ||
* Specify whether users with legacy browsers should be warned | ||
* about their lack of Kibana security compliance. | ||
*/ | ||
warnLegacyBrowsers: boolean; | ||
} | ||
|
||
export type CspConfigType = TypeOf<typeof config.schema>; | ||
|
||
const DEFAULT_RULES = [ | ||
`script-src 'unsafe-eval' 'self'`, | ||
`worker-src blob: 'self'`, | ||
`style-src 'unsafe-inline' 'self'`, | ||
]; | ||
const defaults = { | ||
directives: createCspDirectives(DEFAULT_RULES), | ||
rules: DEFAULT_RULES, | ||
strict: true, | ||
warnLegacyBrowsers: true, | ||
}; | ||
export const config = { | ||
path: 'csp', | ||
schema: schema.object({ | ||
directives: schema.string({ defaultValue: defaults.directives }), | ||
rules: schema.arrayOf(schema.string(), { defaultValue: defaults.rules }), | ||
strict: schema.boolean({ defaultValue: defaults.strict }), | ||
warnLegacyBrowsers: schema.boolean({ defaultValue: defaults.warnLegacyBrowsers }), | ||
}), | ||
}; | ||
|
||
/** | ||
* The default set of CSP options used for Kibana. | ||
* @public | ||
*/ | ||
export const CSP_OPTIONS: Readonly<CspOptions> = Object.freeze(defaults); | ||
|
||
/** | ||
* Converts an array of rules into a formatted directives string for use | ||
* in a `Content-Security-Policy` header. | ||
* @internal | ||
*/ | ||
export function createCspDirectives(rules: string[]) { | ||
return rules.join('; '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.