You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -241,35 +241,136 @@ There are some exceptions where a separate repo makes sense. However, they are e
241
241
242
242
It may be tempting to get caught up in the dream of writing the next package which is published to npm and downloaded millions of times a week. Knowing the quality of developers that are working on Kibana, this is a real possibility. However, knowing which packages will see mass adoption is impossible to predict. Instead of jumping directly to writing code in a separate repo and accepting all of the complications that come along with it, prefer keeping code inside the Kibana repo. A [Kibana package](https://github.com/elastic/kibana/tree/master/packages) can be used to publish a package to npm, while still keeping the code inside the Kibana repo. Move code to an external repo only when there is a good reason, for example to enable external contributions.
243
243
244
-
## Hardening
245
-
246
-
Review the following items related to vulnerability and security risks.
247
-
248
-
- XSS
249
-
- Check for usages of `dangerouslySetInnerHtml`, `Element.innerHTML`, `Element.outerHTML`
250
-
- Ensure all user input is properly escaped.
251
-
- Ensure any input in `$.html`, `$.append`, `$.appendTo`, $.prepend`, `$.prependTo`is escaped. Instead use`$.text`, or don't use jQuery at all.
252
-
- CSRF
253
-
- Ensure all APIs are running inside the Kibana HTTP service.
254
-
- RCE
255
-
- Ensure no usages of `eval`
256
-
- Ensure no usages of dynamic requires
257
-
- Check for template injection
258
-
- Check for usages of templating libraries, including `_.template`, and ensure that user provided input isn't influencing the template and is only used as data for rendering the template.
259
-
- Check for possible prototype pollution.
260
-
- Prototype Pollution - more info [here](https://docs.google.com/document/d/19V-d9sb6IF-fbzF4iyiPpAropQNydCnoJApzSX5FdcI/edit?usp=sharing)
261
-
- Check for instances of `anObject[a][b] = c` where a, b, and c are user defined. This includes code paths where the following logical code steps could be performed in separate files by completely different operations, or recursively using dynamic operations.
262
-
- Validate any user input, including API url-parameters/query-parameters/payloads, preferable against a schema which only allows specific keys/values. At a very minimum, black-list `__proto__` and `prototype.constructor` for use within keys
263
-
- When calling APIs which spawn new processes or potentially perform code generation from strings, defensively protect against Prototype Pollution by checking `Object.hasOwnProperty` if the arguments to the APIs originate from an Object. An example is the Code app's [spawnProcess](https://github.com/elastic/kibana/blob/b49192626a8528af5d888545fb14cd1ce66a72e7/x-pack/legacy/plugins/code/server/lsp/workspace_command.ts#L40-L44).
264
-
- Common Node.js offenders: `child_process.spawn`, `child_process.exec`, `eval`, `Function('some string')`, `vm.runIn*Context(x)`
- Check for accidental reveal of sensitive information
267
-
- The biggest culprit is errors which contain stack traces or other sensitive information which end up in the HTTP Response
268
-
- Checked for Mishandled API requests
269
-
- Ensure no sensitive cookies are forwarded to external resources.
270
-
- Ensure that all user controllable variables that are used in constructing a URL are escaped properly. This is relevant when using `transport.request` with the Elasticsearch client as no automatic escaping is performed.
- When there are user controllable links or hard-coded links to third-party domains that specify target="\_blank" or target="\_window", the `a` tag should have the rel="noreferrer noopener" attribute specified.
273
-
- Allowing users to input markdown is a common culprit, a custom link renderer should be used
Copy file name to clipboardExpand all lines: docs/canvas/canvas-function-reference.asciidoc
+49-8Lines changed: 49 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -71,7 +71,7 @@ Alias: `condition`
71
71
[[alterColumn_fn]]
72
72
=== `alterColumn`
73
73
74
-
Converts between core types, including `string`, `number`, `null`, `boolean`, and `date`, and renames columns. See also <<mapColumn_fn>> and <<staticColumn_fn>>.
74
+
Converts between core types, including `string`, `number`, `null`, `boolean`, and `date`, and renames columns. See also <<mapColumn_fn>>, <<mathColumn_fn>>, and <<staticColumn_fn>>.
75
75
76
76
*Expression syntax*
77
77
[source,js]
@@ -1717,23 +1717,23 @@ Adds a column calculated as the result of other columns. Changes are made only w
1717
1717
|===
1718
1718
|Argument |Type |Description
1719
1719
1720
+
|`id`
1721
+
1722
+
|`string`, `null`
1723
+
|An optional id of the resulting column. When no id is provided, the id will be looked up from the existing column by the provided name argument. If no column with this name exists yet, a new column with this name and an identical id will be added to the table.
1724
+
1720
1725
|_Unnamed_ ***
1721
1726
1722
1727
Aliases: `column`, `name`
1723
1728
|`string`
1724
-
|The name of the resulting column.
1729
+
|The name of the resulting column. Names are not required to be unique.
1725
1730
1726
1731
|`expression` ***
1727
1732
1728
1733
Aliases: `exp`, `fn`, `function`
1729
1734
|`boolean`, `number`, `string`, `null`
1730
1735
|A Canvas expression that is passed to each row as a single row `datatable`.
1731
1736
1732
-
|`id`
1733
-
1734
-
|`string`, `null`
1735
-
|An optional id of the resulting column. When not specified or `null` the name argument is used as id.
1736
-
1737
1737
|`copyMetaFrom`
1738
1738
1739
1739
|`string`, `null`
@@ -1808,6 +1808,47 @@ Default: `"throw"`
1808
1808
*Returns:* `number` | `boolean` | `null`
1809
1809
1810
1810
1811
+
[float]
1812
+
[[mathColumn_fn]]
1813
+
=== `mathColumn`
1814
+
1815
+
Adds a column by evaluating `TinyMath` on each row. This function is optimized for math, so it performs better than the <<mapColumn_fn>> with a <<math_fn>>.
1816
+
*Accepts:* `datatable`
1817
+
1818
+
[cols="3*^<"]
1819
+
|===
1820
+
|Argument |Type |Description
1821
+
1822
+
|id ***
1823
+
|`string`
1824
+
|id of the resulting column. Must be unique.
1825
+
1826
+
|name ***
1827
+
|`string`
1828
+
|The name of the resulting column. Names are not required to be unique.
1829
+
1830
+
|_Unnamed_
1831
+
1832
+
Alias: `expression`
1833
+
|`string`
1834
+
|A `TinyMath` expression evaluated on each row. See https://www.elastic.co/guide/en/kibana/current/canvas-tinymath-functions.html.
1835
+
1836
+
|`onError`
1837
+
1838
+
|`string`
1839
+
|In case the `TinyMath` evaluation fails or returns NaN, the return value is specified by onError. For example, `"null"`, `"zero"`, `"false"`, `"throw"`. When `"throw"`, it will throw an exception, terminating expression execution.
1840
+
1841
+
Default: `"throw"`
1842
+
1843
+
|`copyMetaFrom`
1844
+
1845
+
|`string`, `null`
1846
+
|If set, the meta object from the specified column id is copied over to the specified target column. Throws an exception if the column doesn't exist
1847
+
|===
1848
+
1849
+
*Returns:* `datatable`
1850
+
1851
+
1811
1852
[float]
1812
1853
[[metric_fn]]
1813
1854
=== `metric`
@@ -2581,7 +2622,7 @@ Default: `false`
2581
2622
[[staticColumn_fn]]
2582
2623
=== `staticColumn`
2583
2624
2584
-
Adds a column with the same static value in every row. See also <<alterColumn_fn>>and <<mapColumn_fn>>.
2625
+
Adds a column with the same static value in every row. See also <<alterColumn_fn>>, <<mapColumn_fn>>, and <<mathColumn_fn>>.
0 commit comments