Skip to content

Commit

Permalink
Merge branch 'main' into asset-criticality-alert-enrichment
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhristinin committed Dec 21, 2023
2 parents 84c8da9 + 3def20e commit 5c1de12
Show file tree
Hide file tree
Showing 305 changed files with 3,873 additions and 1,557 deletions.
5 changes: 0 additions & 5 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -1497,17 +1497,12 @@ x-pack/test/threat_intelligence_cypress @elastic/protections-experience
x-pack/plugins/security_solution/common/entity_analytics @elastic/security-entity-analytics
x-pack/plugins/security_solution/common/search_strategy/security_solution/risk_score @elastic/security-entity-analytics
x-pack/plugins/security_solution/public/entity_analytics @elastic/security-entity-analytics
x-pack/plugins/security_solution/public/explore/components/risk_score @elastic/security-entity-analytics
x-pack/plugins/security_solution/public/overview/pages/entity_analytics.tsx @elastic/security-entity-analytics
x-pack/plugins/security_solution/public/overview/components/entity_analytics
x-pack/plugins/security_solution/server/lib/entity_analytics @elastic/security-entity-analytics
x-pack/plugins/security_solution/server/lib/risk_score @elastic/security-entity-analytics
x-pack/test/security_solution_api_integration/test_suites/entity_analytics @elastic/security-entity-analytics
x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics @elastic/security-entity-analytics
x-pack/plugins/security_solution/public/flyout/entity_details @elastic/security-entity-analytics
x-pack/plugins/security_solution/common/api/entity_analytics @elastic/security-entity-analytics
/x-pack/plugins/security_solution/public/entity_analytics @elastic/security-entity-analytics
/x-pack/test/security_solution_cypress/cypress/e2e/entity_analytics @elastic/security-entity-analytics

# Security Defend Workflows - OSQuery Ownership
/x-pack/plugins/security_solution/common/api/detection_engine/model/rule_response_actions @elastic/security-defend-workflows
Expand Down
1 change: 1 addition & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ yarn_install(
"GECKODRIVER_CDNURL": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache",
"CHROMEDRIVER_CDNURL": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache",
"CHROMEDRIVER_CDNBINARIESURL": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache",
"SASS_BINARY_SITE": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-sass",
"RE2_DOWNLOAD_MIRROR": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2",
"CYPRESS_DOWNLOAD_MIRROR": "https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/cypress",
}
Expand Down
2 changes: 2 additions & 0 deletions kbn_pm/src/lib/bazel.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ export async function installYarnDeps(log, opts = undefined) {
offline: opts?.offline,
quiet: opts?.quiet,
env: {
SASS_BINARY_SITE:
'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-sass',
RE2_DOWNLOAD_MIRROR:
'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2',
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,7 @@
"mutation-observer": "^1.0.3",
"native-hdr-histogram": "^1.0.0",
"nock": "12.0.3",
"node-sass": "^8.0.0",
"null-loader": "^3.0.0",
"nyc": "^15.1.0",
"oboe": "^2.1.4",
Expand Down Expand Up @@ -1624,8 +1625,7 @@
"regenerate": "^1.4.0",
"resolve": "^1.22.0",
"rxjs-marbles": "^7.0.1",
"sass-embedded": "^1.69.5",
"sass-loader": "^10.5.0",
"sass-loader": "^10.4.1",
"selenium-webdriver": "^4.16.0",
"simple-git": "^3.16.0",
"sinon": "^7.4.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-dom-drag-drop/src/sass/drag_drop.scss
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ $reorderItemMargin: $euiSizeS;
position: absolute;
width: 100%;
top: 0;
height: calc(100% + #{calc($reorderItemMargin / 2)});
height: calc(100% + #{$reorderItemMargin / 2});
}

.domDragDrop-translatableDrop {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export class ESQLTokensProvider implements monaco.languages.TokensProvider {
const tokenTypeName = lexer.vocabulary.getSymbolicName(token.type);

if (tokenTypeName) {
const myToken = new ESQLToken(tokenTypeName, token.startIndex, token.stopIndex);
const indexOffset = cleanedLine === line ? 0 : line.length - cleanedLine.length;
const myToken = new ESQLToken(
tokenTypeName,
token.startIndex + indexOffset,
token.stopIndex + indexOffset
);
myTokens.push(myToken);
}
}
Expand Down
8 changes: 4 additions & 4 deletions packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ export function getWebpackConfig(
)
)};\n${content}`;
},
implementation: require('sass-embedded'),
webpackImporter: false,
implementation: require('node-sass'),
sassOptions: {
outputStyle: worker.dist ? 'compressed' : 'expanded',
outputStyle: worker.dist ? 'compressed' : 'nested',
includePaths: [Path.resolve(worker.repoRoot, 'node_modules')],
sourceMap: true,
quietDeps: true,
sourceMapRoot: `/${bundle.type}:${bundle.id}`,
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-rule-data-utils/src/rule_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ export type RuleCreationValidConsumer =
| typeof AlertConsumers.LOGS
| typeof AlertConsumers.INFRASTRUCTURE
| typeof AlertConsumers.OBSERVABILITY
| typeof STACK_ALERTS_FEATURE_ID;
| typeof STACK_ALERTS_FEATURE_ID
| 'alerts';
1 change: 1 addition & 0 deletions packages/kbn-rule-data-utils/src/rule_types/stack_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@

export const STACK_ALERTS_FEATURE_ID = 'stackAlerts';
export const ES_QUERY_ID = '.es-query';
export const ML_ANOMALY_DETECTION_RULE_TYPE_ID = 'xpack.ml.anomaly_detection_alert';
3 changes: 1 addition & 2 deletions packages/kbn-storybook/src/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,9 @@ export default ({ config: storybookConfig }: { config: Configuration }) => {
resolve(REPO_ROOT, 'src/core/public/styles/core_app/_globals_v8light.scss')
)};\n${content}`;
},
implementation: require('sass-embedded'),
implementation: require('node-sass'),
sassOptions: {
includePaths: [resolve(REPO_ROOT, 'node_modules')],
quietDeps: true,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

.unifiedFieldListSidebar .unifiedFieldListItemButton {
&.kbnFieldButton {
margin-bottom: calc($euiSizeXS / 2);
margin-bottom: $euiSizeXS / 2;
}

&.domDragDrop-isDraggable {
Expand Down
4 changes: 2 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
{
"groupName": "scss",
"packageNames": [
"sass-embedded"
"node-sass"
],
"reviewers": [
"team:kibana-operations"
Expand Down Expand Up @@ -673,4 +673,4 @@
"enabled": true
}
]
}
}
2 changes: 2 additions & 0 deletions src/dev/build/tasks/install_dependencies_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export const InstallDependencies: Task = {
{
cwd: build.resolvePath(),
env: {
SASS_BINARY_SITE:
'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-sass',
RE2_DOWNLOAD_MIRROR:
'https://us-central1-elastic-kibana-184716.cloudfunctions.net/kibana-ci-proxy-cache/node-re2',
},
Expand Down
1 change: 0 additions & 1 deletion src/dev/license_checker/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,4 @@ export const LICENSE_OVERRIDES = {
'@elastic/eui@91.0.0-backport.0': ['SSPL-1.0 OR Elastic License 2.0'],
'language-subtag-registry@0.3.21': ['CC-BY-4.0'], // retired ODC‑By license https://github.com/mattcg/language-subtag-registry
'buffers@0.1.1': ['MIT'], // license in importing module https://www.npmjs.com/package/binary
'@bufbuild/protobuf@1.2.1': ['Apache-2.0'], // license (Apache-2.0 AND BSD-3-Clause)
};
2 changes: 1 addition & 1 deletion src/plugins/console/public/styles/_app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
padding: 0 $euiSizeS;
display: inline-block;
text-decoration: none;
border-radius: calc($euiBorderRadius / 2);
border-radius: $euiBorderRadius / 2;
white-space: nowrap;
vertical-align: middle;
cursor: default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
}

.optionsList__actionsRow {
margin: calc($euiSizeS / 2) 0 !important;
margin: ($euiSizeS / 2) 0 !important;

.optionsList__actionBarDivider {
height: $euiSize;
Expand Down Expand Up @@ -97,4 +97,4 @@
color: $euiTextSubduedColor;
padding: $euiSizeM;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
dt {
background-color: transparentize(shade($euiColorPrimary, 20%), .9);
color: $euiTextColor;
padding: calc($euiSizeXS / 2) $euiSizeXS;
padding: ($euiSizeXS / 2) $euiSizeXS;
margin-right: $euiSizeXS;
word-break: normal;
border-radius: $euiBorderRadius;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_react/public/markdown/_markdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$kbnDefaultFontSize: 14px;

@function canvasToEm($size) {
@return #{calc($size / $kbnDefaultFontSize)}em;
@return #{$size / $kbnDefaultFontSize}em;
}

.kbnMarkdown__body {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
line-height: $euiSize;
border: none;
color: $euiTextColor;
padding-top: calc($euiSizeM / 2) + 1px;
padding-bottom: calc($euiSizeM / 2) + 1px;
padding-top: $euiSizeM / 2 + 1px;
padding-bottom: $euiSizeM / 2 + 1px;
white-space: normal; /* 1 */

&:not(.globalFilterItem-isDisabled) {
Expand Down Expand Up @@ -54,8 +54,8 @@
left: 0;
width: $euiSizeXS;
background-color: $kbnGlobalFilterItemBorderColor;
border-top-left-radius: calc($euiBorderRadius / 2);
border-bottom-left-radius: calc($euiBorderRadius / 2);
border-top-left-radius: $euiBorderRadius / 2;
border-bottom-left-radius: $euiBorderRadius / 2;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
}

.kbnSavedQueryManagement__text {
padding: $euiSizeM $euiSizeM calc($euiSizeM / 2) $euiSizeM;
padding: $euiSizeM $euiSizeM ($euiSizeM / 2) $euiSizeM;
}

.kbnSavedQueryManagement__list {
@include euiYScrollWithShadows;
max-height: inherit; // Fixes overflow for applied max-height
// Left/Right padding is calculated to match the left alignment of the
// popover text and buttons
padding: calc($euiSizeM / 2) $euiSizeXS !important; // Override flush
padding: ($euiSizeM / 2) $euiSizeXS !important; // Override flush
}
2 changes: 1 addition & 1 deletion src/plugins/vis_default_editor/public/_agg_params.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.visEditorAggParam--half {
margin: $euiSize 0;
display: inline-block;
width: calc(50% - #{calc($euiSizeS / 2)});
width: calc(50% - #{$euiSizeS / 2});
}

.visEditorAggParam--half-size {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
> .tvbVis {
// Apply the minimum height on the vis itself so it doesn't interfere with flex calculations
// Gauges are not completely square, so the height is just slightly less than the width
min-height: calc($euiSize * 12 / 1.25);
min-height: $euiSize * 12 / 1.25;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
.tvbVisMetric__label--additional {
@include euiTextTruncate;
font-size: .25em; /* 1 */
padding: calc($euiSizeXS / 2) 0 0;
padding: ($euiSizeXS / 2) 0 0;
text-align: center;
color: $tvbValueColor;
line-height: 1.2; // Ensure the descenders don't get cut off
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
}

.slice {
stroke-width: calc($euiSizeXS / 2);
stroke-width: $euiSizeXS / 2;
stroke: $euiColorEmptyShade;

&:hover {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export const AssistantOverlay = React.memo(() => {
WELCOME_CONVERSATION_TITLE
);
const [promptContextId, setPromptContextId] = useState<string | undefined>();
const { assistantTelemetry, setShowAssistantOverlay, localStorageLastConversationId } =
useAssistantContext();
const { assistantTelemetry, setShowAssistantOverlay, getConversationId } = useAssistantContext();

// Bind `showAssistantOverlay` in SecurityAssistantContext to this modal instance
const showOverlay = useCallback(
Expand All @@ -44,16 +43,18 @@ export const AssistantOverlay = React.memo(() => {
promptContextId: pid,
conversationId: cid,
}: ShowAssistantOverlayProps) => {
const newConversationId = getConversationId(cid);
if (so)
assistantTelemetry?.reportAssistantInvoked({
conversationId: cid ?? 'unknown',
conversationId: newConversationId,
invokedBy: 'click',
});

setIsModalVisible(so);
setPromptContextId(pid);
setConversationId(cid);
setConversationId(newConversationId);
},
[assistantTelemetry]
[assistantTelemetry, getConversationId]
);
useEffect(() => {
setShowAssistantOverlay(showOverlay);
Expand All @@ -63,15 +64,15 @@ export const AssistantOverlay = React.memo(() => {
const handleShortcutPress = useCallback(() => {
// Try to restore the last conversation on shortcut pressed
if (!isModalVisible) {
setConversationId(localStorageLastConversationId ?? WELCOME_CONVERSATION_TITLE);
setConversationId(getConversationId());
assistantTelemetry?.reportAssistantInvoked({
invokedBy: 'shortcut',
conversationId: localStorageLastConversationId ?? WELCOME_CONVERSATION_TITLE,
conversationId: getConversationId(),
});
}

setIsModalVisible(!isModalVisible);
}, [assistantTelemetry, isModalVisible, localStorageLastConversationId]);
}, [assistantTelemetry, isModalVisible, getConversationId]);

// Register keyboard listener to show the modal when cmd + ; is pressed
const onKeyDown = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const AssistantComponent: React.FC<Props> = ({
http,
promptContexts,
setLastConversationId,
localStorageLastConversationId,
getConversationId,
title,
allSystemPrompts,
} = useAssistantContext();
Expand Down Expand Up @@ -113,12 +113,7 @@ const AssistantComponent: React.FC<Props> = ({
);

const [selectedConversationId, setSelectedConversationId] = useState<string>(
isAssistantEnabled
? // if a conversationId has been provided, use that
// if not, check local storage
// last resort, go to welcome conversation
conversationId ?? localStorageLastConversationId ?? WELCOME_CONVERSATION_TITLE
: WELCOME_CONVERSATION_TITLE
isAssistantEnabled ? getConversationId(conversationId) : WELCOME_CONVERSATION_TITLE
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import { AssistantProvider, useAssistantContext } from '.';
import { httpServiceMock } from '@kbn/core-http-browser-mocks';
import { actionTypeRegistryMock } from '@kbn/triggers-actions-ui-plugin/public/application/action_type_registry.mock';
import { AssistantAvailability } from '../..';
import { useLocalStorage } from 'react-use';

jest.mock('react-use', () => ({
useLocalStorage: jest.fn().mockReturnValue(['456', jest.fn()]),
}));
const actionTypeRegistry = actionTypeRegistryMock.create();
const mockGetInitialConversations = jest.fn(() => ({}));
const mockGetComments = jest.fn(() => []);
Expand Down Expand Up @@ -70,4 +74,23 @@ describe('AssistantContext', () => {

expect(mockHttp.fetch).toBeCalledWith(path);
});

test('getConversationId defaults to provided id', async () => {
const { result } = renderHook(useAssistantContext, { wrapper: ContextWrapper });
const id = result.current.getConversationId('123');
expect(id).toEqual('123');
});

test('getConversationId uses local storage id when no id is provided ', async () => {
const { result } = renderHook(useAssistantContext, { wrapper: ContextWrapper });
const id = result.current.getConversationId();
expect(id).toEqual('456');
});

test('getConversationId defaults to Welcome when no local storage id and no id is provided ', async () => {
(useLocalStorage as jest.Mock).mockReturnValue([undefined, jest.fn()]);
const { result } = renderHook(useAssistantContext, { wrapper: ContextWrapper });
const id = result.current.getConversationId();
expect(id).toEqual('Welcome');
});
});
Loading

0 comments on commit 5c1de12

Please sign in to comment.