2023-12-12 21:03:33 +00:00
|
|
|
import {
|
|
|
|
|
ISoftware,
|
|
|
|
|
ISoftwareVersion,
|
|
|
|
|
ISoftwareVulnerability,
|
|
|
|
|
ISoftwareTitleVersion,
|
2024-05-09 13:06:58 +00:00
|
|
|
ISoftwarePackage,
|
2024-07-18 09:20:17 +00:00
|
|
|
ISoftwareTitle,
|
|
|
|
|
ISoftwareTitleDetails,
|
|
|
|
|
IAppStoreApp,
|
2024-09-20 14:47:01 +00:00
|
|
|
IFleetMaintainedApp,
|
|
|
|
|
IFleetMaintainedAppDetails,
|
2023-12-12 21:03:33 +00:00
|
|
|
} from "interfaces/software";
|
|
|
|
|
import {
|
|
|
|
|
ISoftwareTitlesResponse,
|
|
|
|
|
ISoftwareTitleResponse,
|
|
|
|
|
ISoftwareVersionsResponse,
|
|
|
|
|
ISoftwareVersionResponse,
|
|
|
|
|
} from "services/entities/software";
|
2024-08-30 23:12:19 +00:00
|
|
|
import { IOSVersionsResponse } from "../services/entities/operating_systems";
|
|
|
|
|
import { IOperatingSystemVersion } from "../interfaces/operating_system";
|
2022-11-01 18:59:40 +00:00
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_MOCK: ISoftware = {
|
|
|
|
|
hosts_count: 1,
|
|
|
|
|
id: 1,
|
|
|
|
|
name: "mock software 1.app",
|
|
|
|
|
version: "1.0.0",
|
|
|
|
|
source: "apps",
|
|
|
|
|
generated_cpe: "",
|
|
|
|
|
vulnerabilities: null,
|
|
|
|
|
last_opened_at: null,
|
|
|
|
|
bundle_identifier: "com.app.mock",
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-12 21:03:33 +00:00
|
|
|
export const createMockSoftware = (
|
|
|
|
|
overrides?: Partial<ISoftware>
|
|
|
|
|
): ISoftware => {
|
2022-11-01 18:59:40 +00:00
|
|
|
return { ...DEFAULT_SOFTWARE_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-12 21:03:33 +00:00
|
|
|
const DEFAULT_SOFTWARE_TITLE_VERSION_MOCK = {
|
|
|
|
|
id: 1,
|
|
|
|
|
version: "1.0.0",
|
|
|
|
|
vulnerabilities: ["CVE-2020-0001"],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareTitleVersion = (
|
|
|
|
|
overrides?: Partial<ISoftwareTitleVersion>
|
|
|
|
|
): ISoftwareTitleVersion => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_TITLE_VERSION_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_VULNERABILITY_MOCK = {
|
|
|
|
|
cve: "CVE-2020-0001",
|
|
|
|
|
details_link: "https://test.com",
|
|
|
|
|
cvss_score: 9,
|
|
|
|
|
epss_probability: 0.8,
|
|
|
|
|
cisa_known_exploit: false,
|
|
|
|
|
cve_published: "2020-01-01T00:00:00.000Z",
|
|
|
|
|
cve_description: "test description",
|
|
|
|
|
resolved_in_version: "1.2.3",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareVulnerability = (
|
|
|
|
|
overrides?: Partial<ISoftwareVulnerability>
|
|
|
|
|
): ISoftwareVulnerability => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_VULNERABILITY_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_VERSION_MOCK: ISoftwareVersion = {
|
|
|
|
|
id: 1,
|
|
|
|
|
name: "test.app",
|
|
|
|
|
version: "1.2.3",
|
|
|
|
|
bundle_identifier: "com.test.Desktop",
|
2024-10-08 19:19:32 +00:00
|
|
|
source: "apps",
|
|
|
|
|
browser: "chrome",
|
2023-12-12 21:03:33 +00:00
|
|
|
release: "1",
|
|
|
|
|
vendor: "test_vendor",
|
|
|
|
|
arch: "x86_64",
|
|
|
|
|
generated_cpe: "cpe:test:app:1.2.3",
|
|
|
|
|
vulnerabilities: [createMockSoftwareVulnerability()],
|
|
|
|
|
hosts_count: 1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareVersion = (
|
|
|
|
|
overrides?: Partial<ISoftwareVersion>
|
|
|
|
|
): ISoftwareVersion => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_VERSION_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_VERSIONS_RESPONSE_MOCK: ISoftwareVersionsResponse = {
|
|
|
|
|
counts_updated_at: "2020-01-01T00:00:00.000Z",
|
|
|
|
|
count: 1,
|
|
|
|
|
software: [createMockSoftwareVersion()],
|
|
|
|
|
meta: {
|
|
|
|
|
has_next_results: false,
|
|
|
|
|
has_previous_results: false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-30 23:12:19 +00:00
|
|
|
export const createMockSoftwareVersionsResponse = (
|
2023-12-12 21:03:33 +00:00
|
|
|
overrides?: Partial<ISoftwareVersionsResponse>
|
|
|
|
|
): ISoftwareVersionsResponse => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_VERSIONS_RESPONSE_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-30 23:12:19 +00:00
|
|
|
const DEFAULT_OS_VERSION_MOCK = {
|
|
|
|
|
os_version_id: 1,
|
|
|
|
|
name: "macOS 14.6.1",
|
|
|
|
|
name_only: "macOS",
|
|
|
|
|
version: "14.6.1",
|
|
|
|
|
platform: "darwin",
|
|
|
|
|
hosts_count: 42,
|
|
|
|
|
generated_cpes: [],
|
|
|
|
|
vulnerabilities: [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockOSVersion = (
|
|
|
|
|
overrides?: Partial<IOperatingSystemVersion>
|
|
|
|
|
): IOperatingSystemVersion => {
|
|
|
|
|
return {
|
|
|
|
|
...DEFAULT_OS_VERSION_MOCK,
|
|
|
|
|
...overrides,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_OS_VERSIONS_RESPONSE_MOCK: IOSVersionsResponse = {
|
|
|
|
|
counts_updated_at: "2020-01-01T00:00:00.000Z",
|
|
|
|
|
count: 1,
|
|
|
|
|
os_versions: [createMockOSVersion()],
|
|
|
|
|
meta: {
|
|
|
|
|
has_next_results: false,
|
|
|
|
|
has_previous_results: false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockOSVersionsResponse = (
|
|
|
|
|
overrides?: Partial<IOSVersionsResponse>
|
|
|
|
|
): IOSVersionsResponse => {
|
|
|
|
|
return { ...DEFAULT_OS_VERSIONS_RESPONSE_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
2024-07-18 09:20:17 +00:00
|
|
|
const DEFAULT_APP_STORE_APP_MOCK: IAppStoreApp = {
|
|
|
|
|
name: "test app",
|
|
|
|
|
app_store_id: 1,
|
|
|
|
|
icon_url: "https://via.placeholder.com/512",
|
|
|
|
|
latest_version: "1.2.3",
|
2024-08-20 14:51:36 +00:00
|
|
|
self_service: true,
|
2024-07-18 09:20:17 +00:00
|
|
|
status: {
|
|
|
|
|
installed: 1,
|
|
|
|
|
pending: 2,
|
|
|
|
|
failed: 3,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockAppStoreApp = (overrides?: Partial<IAppStoreApp>) => {
|
|
|
|
|
return { ...DEFAULT_APP_STORE_APP_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_TITLE_DETAILS_MOCK: ISoftwareTitleDetails = {
|
|
|
|
|
id: 1,
|
|
|
|
|
name: "test.app",
|
|
|
|
|
software_package: null,
|
|
|
|
|
app_store_app: null,
|
2024-10-08 19:19:32 +00:00
|
|
|
source: "apps",
|
2024-07-18 09:20:17 +00:00
|
|
|
hosts_count: 1,
|
|
|
|
|
versions: [createMockSoftwareTitleVersion()],
|
|
|
|
|
bundle_identifier: "com.test.Desktop",
|
|
|
|
|
versions_count: 1,
|
2024-11-05 15:54:02 +00:00
|
|
|
counts_updated_at: "2024-11-01T01:23:45Z",
|
2024-07-18 09:20:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareTitleDetails = (
|
|
|
|
|
overrides?: Partial<ISoftwareTitleDetails>
|
|
|
|
|
) => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_TITLE_DETAILS_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_TITLE_RESPONSE: ISoftwareTitleResponse = {
|
|
|
|
|
software_title: createMockSoftwareTitleDetails(),
|
2023-12-12 21:03:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareTitleResponse = (
|
2024-07-18 09:20:17 +00:00
|
|
|
overrides?: Partial<ISoftwareTitleResponse>
|
2023-12-12 21:03:33 +00:00
|
|
|
): ISoftwareTitleResponse => {
|
2024-07-18 09:20:17 +00:00
|
|
|
return { ...DEFAULT_SOFTWARE_TITLE_RESPONSE, ...overrides };
|
2023-12-12 21:03:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_VERSION_RESPONSE = {
|
|
|
|
|
software: createMockSoftwareVersion(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareVersionResponse = (
|
|
|
|
|
overrides?: Partial<ISoftwareVersionResponse>
|
|
|
|
|
): ISoftwareVersionResponse => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_VERSION_RESPONSE, ...overrides };
|
|
|
|
|
};
|
2024-05-09 13:06:58 +00:00
|
|
|
|
2024-07-18 16:04:15 +00:00
|
|
|
const DEFAULT_SOFTWARE_PACKAGE_MOCK: ISoftwarePackage = {
|
2024-05-09 13:06:58 +00:00
|
|
|
name: "TestPackage-1.2.3.pkg",
|
|
|
|
|
version: "1.2.3",
|
|
|
|
|
uploaded_at: "2020-01-01T00:00:00.000Z",
|
|
|
|
|
install_script: "sudo installer -pkg /temp/FalconSensor-6.44.pkg -target /",
|
|
|
|
|
pre_install_query: "SELECT 1 FROM macos_profiles WHERE uuid='abc123';",
|
|
|
|
|
post_install_script:
|
|
|
|
|
"sudo /Applications/Falcon.app/Contents/Resources/falconctl license abc123",
|
Update UI for software self-service features (#19244)
Issues https://github.com/fleetdm/fleet/issues/17587,
https://github.com/fleetdm/fleet/issues/18836,
https://github.com/fleetdm/fleet/issues/18837,
https://github.com/fleetdm/fleet/pull/18339, and
https://github.com/fleetdm/fleet/pull/18340
# TODOS
- Integrate backend
- Unit/integration tests
- Various todos noted in comments
- Cleanup styles and organization of components (de-duplicating and
consolidating where possible)
- Activity feed updates (if any)
# Checklist for submitter
If some of the following don't apply, delete the relevant line.
<!-- Note that API documentation changes are now addressed by the
product design team. -->
- [ ] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://fleetdm.com/docs/contributing/committing-changes#changes-files)
for more information.
- [ ] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [ ] Added support on fleet's osquery simulator `cmd/osquery-perf` for
new osquery data ingestion features.
- [ ] Added/updated tests
- [ ] If database migrations are included, checked table schema to
confirm autoupdate
- For database migrations:
- [ ] Checked schema for all modified table for columns that will
auto-update timestamps during migration.
- [ ] Confirmed that updating the timestamps is acceptable, and will not
cause unwanted side effects.
- [ ] Ensured the correct collation is explicitly set for character
columns (`COLLATE utf8mb4_unicode_ci`).
- [ ] Manual QA for all new/changed functionality
- For Orbit and Fleet Desktop changes:
- [ ] Manual QA must be performed in the three main OSs, macOS, Windows
and Linux.
- [ ] Auto-update manual QA, from released version of component to new
version (see [tools/tuf/test](../tools/tuf/test/README.md)).
---------
Co-authored-by: Gabriel Hernandez <ghernandez345@gmail.com>
2024-05-31 10:09:53 +00:00
|
|
|
self_service: false,
|
2024-07-18 16:04:15 +00:00
|
|
|
icon_url: null,
|
2024-05-09 13:06:58 +00:00
|
|
|
status: {
|
|
|
|
|
installed: 1,
|
2024-09-12 15:51:59 +00:00
|
|
|
pending_install: 2,
|
|
|
|
|
failed_install: 1,
|
|
|
|
|
pending_uninstall: 1,
|
|
|
|
|
failed_uninstall: 1,
|
2024-05-09 13:06:58 +00:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwarePackage = (
|
|
|
|
|
overrides?: Partial<ISoftwarePackage>
|
|
|
|
|
) => {
|
2024-07-18 16:04:15 +00:00
|
|
|
return { ...DEFAULT_SOFTWARE_PACKAGE_MOCK, ...overrides };
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_TITLE_MOCK: ISoftwareTitle = {
|
|
|
|
|
id: 1,
|
|
|
|
|
name: "mock software 1.app",
|
|
|
|
|
versions_count: 1,
|
|
|
|
|
source: "apps",
|
|
|
|
|
hosts_count: 1,
|
|
|
|
|
browser: "chrome",
|
|
|
|
|
versions: [createMockSoftwareTitleVersion()],
|
|
|
|
|
software_package: createMockSoftwarePackage(),
|
|
|
|
|
app_store_app: null,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockSoftwareTitle = (
|
|
|
|
|
overrides?: Partial<ISoftwareTitle>
|
|
|
|
|
): ISoftwareTitle => {
|
|
|
|
|
return {
|
|
|
|
|
...DEFAULT_SOFTWARE_TITLE_MOCK,
|
|
|
|
|
...overrides,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_SOFTWARE_TITLES_RESPONSE_MOCK: ISoftwareTitlesResponse = {
|
|
|
|
|
counts_updated_at: "2020-01-01T00:00:00.000Z",
|
|
|
|
|
count: 1,
|
|
|
|
|
software_titles: [createMockSoftwareTitle()],
|
|
|
|
|
meta: {
|
|
|
|
|
has_next_results: false,
|
|
|
|
|
has_previous_results: false,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2024-08-30 23:12:19 +00:00
|
|
|
export const createMockSoftwareTitlesResponse = (
|
2024-07-18 16:04:15 +00:00
|
|
|
overrides?: Partial<ISoftwareTitlesResponse>
|
|
|
|
|
): ISoftwareTitlesResponse => {
|
|
|
|
|
return { ...DEFAULT_SOFTWARE_TITLES_RESPONSE_MOCK, ...overrides };
|
2024-05-09 13:06:58 +00:00
|
|
|
};
|
2024-09-20 14:47:01 +00:00
|
|
|
|
|
|
|
|
const DEFAULT_FLEET_MAINTAINED_APPS_MOCK: IFleetMaintainedApp = {
|
|
|
|
|
id: 1,
|
|
|
|
|
name: "test app",
|
|
|
|
|
version: "1.2.3",
|
|
|
|
|
platform: "darwin",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockFleetMaintainedApp = (
|
|
|
|
|
overrides?: Partial<IFleetMaintainedApp>
|
|
|
|
|
): IFleetMaintainedApp => {
|
|
|
|
|
return {
|
|
|
|
|
...DEFAULT_FLEET_MAINTAINED_APPS_MOCK,
|
|
|
|
|
...overrides,
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const DEFAULT_FLEET_MAINTAINED_APP_DETAILS_MOCK: IFleetMaintainedAppDetails = {
|
|
|
|
|
id: 1,
|
|
|
|
|
name: "Test app",
|
|
|
|
|
version: "1.2.3",
|
|
|
|
|
platform: "darwin",
|
|
|
|
|
pre_install_script: "SELECT * FROM osquery_info WHERE start_time > 1",
|
|
|
|
|
install_script: '#!/bin/sh\n\ninstaller -pkg "$INSTALLER" -target /',
|
|
|
|
|
post_install_script: 'echo "Installed"',
|
|
|
|
|
uninstall_script:
|
|
|
|
|
"#!/bin/sh\n\n# Fleet extracts and saves package IDs\npkg_ids=$PACKAGE_ID",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createMockFleetMaintainedAppDetails = (
|
|
|
|
|
overrides?: Partial<IFleetMaintainedAppDetails>
|
|
|
|
|
) => {
|
|
|
|
|
return { ...DEFAULT_FLEET_MAINTAINED_APP_DETAILS_MOCK, ...overrides };
|
|
|
|
|
};
|