[Security Solution][Endpoint] Add --version to the run SentinelOne and Microsoft host scripts (#209769)

## Summary

- Fixes Cypress `parallel.ts` runner to ensure a failure is reported in
conditions where the setup of the test run environment fails to be
craeted
- Adds the `--version` CLI argument to the `run_sentinelone_host` and
`run_microsoft_defender_host` scripts
- Fixes `run_endpoint_host` script to ensure the `--version` (if
defined) is also used for running fleet-server
This commit is contained in:
Paul Tavares 2025-02-06 11:03:38 -05:00 committed by GitHub
parent 4ee3b50584
commit 5da812ceda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 30 additions and 3 deletions

View file

@ -178,6 +178,6 @@ const getElasticAgentDockerArgs = ({
'--env',
'FLEET_INSECURE=true',
'--rm',
`docker.elastic.co/beats/elastic-agent:${agentVersion}`,
`docker.elastic.co/elastic-agent/elastic-agent:${agentVersion}`,
];
};

View file

@ -498,7 +498,7 @@ const getFleetServerManagedDockerArgs = ({
'--publish',
`${port}:8220`,
`docker.elastic.co/beats/elastic-agent:${agentVersion}`,
`docker.elastic.co/elastic-agent/elastic-agent:${agentVersion}`,
];
};

View file

@ -28,6 +28,7 @@ export const setupAll = async (options: StartRuntimeServicesOptions) => {
await startFleetServerIfNecessary({
kbnClient,
logger: log,
version: options.version,
});
await enrollEndpointHost();

View file

@ -60,6 +60,7 @@ console and pushes the data to Elasticsearch.`,
'vmName',
'spaceId',
'apiKey',
'version',
],
boolean: ['forceFleetServer', 'forceNewHost'],
default: {
@ -106,6 +107,10 @@ console and pushes the data to Elasticsearch.`,
--spaceId Optional. The space id where the host should be added to in kibana. The
space will be created if it does not exist. Default: default space.
--kibanaUrl Optional. The url to Kibana (Default: http://127.0.0.1:5601)
--version Optional. The version of the Agent to use for enrolling the new host.
Default: uses the same version as the stack (kibana). Version
can also be from 'SNAPSHOT'.
Examples: 8.6.0, 8.7.0-SNAPSHOT
`,
},
});
@ -128,6 +133,7 @@ const runCli: RunFn = async ({ log, flags }) => {
const forceFleetServer = flags.forceFleetServer as boolean;
const forceNewHost = flags.forceNewHost as boolean;
const vmName = flags.vmName as string;
const version = flags.version as string | undefined;
const getRequiredArgMessage = (argName: string) => `${argName} argument is required`;
@ -207,6 +213,7 @@ const runCli: RunFn = async ({ log, flags }) => {
kbnClient,
logger: log,
force: forceFleetServer,
version,
});
}
@ -215,6 +222,7 @@ const runCli: RunFn = async ({ log, flags }) => {
kbnClient,
log,
agentPolicyId,
version,
});
} else {
log.debug(

View file

@ -94,6 +94,10 @@ console and pushes the data to Elasticsearch.`,
--spaceId Optional. The space id where the host should be added to in kibana. The
space will be created if it does not exist. Default: default space.
--kibanaUrl Optional. The url to Kibana (Default: http://127.0.0.1:5601)
--version Optional. The version of the Agent to use for enrolling the new host.
Default: uses the same version as the stack (kibana). Version
can also be from 'SNAPSHOT'.
Examples: 8.6.0, 8.7.0-SNAPSHOT
`,
},
});
@ -110,6 +114,7 @@ const runCli: RunFn = async ({ log, flags }) => {
const apiKey = flags.apiKey as string;
const forceFleetServer = flags.forceFleetServer as boolean;
const forceNewS1Host = flags.forceNewS1Host as boolean;
const version = flags.version as string | undefined;
const getRequiredArgMessage = (argName: string) => `${argName} argument is required`;
createToolingLogger.setDefaultLogLevelFromCliFlags(flags);
@ -207,6 +212,7 @@ const runCli: RunFn = async ({ log, flags }) => {
kbnClient,
logger: log,
force: forceFleetServer,
version,
});
}
@ -215,6 +221,7 @@ const runCli: RunFn = async ({ log, flags }) => {
kbnClient,
log,
agentPolicyId,
version,
});
} else {
log.debug(

View file

@ -470,6 +470,17 @@ ${JSON.stringify(cyCustomEnv, null, 2)}
}
} catch (error) {
log.error(error);
if (!result) {
// `result` will be `undefined` when the process above does not reach the `cypress.run()`.
// This can happen when there are errors setting up the run environment, and thus, we need
// ensure we report the run as a failure.
result = {
status: 'failed',
failures: 1,
message: error.message,
};
}
}
if (fleetServer) {

View file

@ -41,7 +41,7 @@ export class AgentManager extends Manager {
public async setup() {
this.log.info(chalk.bold('Setting up Agent'));
const artifact = `docker.elastic.co/beats/elastic-agent:${await getLatestVersion()}`;
const artifact = `docker.elastic.co/elastic-agent/elastic-agent:${await getLatestVersion()}`;
this.log.indent(4, () => this.log.info(`Image: ${artifact}`));
const containerName = generateRandomString(12);
const fleetServerUrl =