fleet/frontend/interfaces/software.ts

345 lines
9.3 KiB
TypeScript
Raw Normal View History

import { startCase } from "lodash";
import PropTypes from "prop-types";
2024-07-16 17:16:57 +00:00
import { IconNames } from "components/icons";
import vulnerabilityInterface from "./vulnerability";
export default PropTypes.shape({
type: PropTypes.string,
name: PropTypes.string,
version: PropTypes.string,
source: PropTypes.string,
id: PropTypes.number,
vulnerabilities: PropTypes.arrayOf(vulnerabilityInterface),
});
export interface ISoftwareResponse {
counts_updated_at: string;
software: ISoftware[];
}
export interface ISoftwareCountResponse {
count: number;
}
export interface IGetSoftwareByIdResponse {
software: ISoftware;
}
// TODO: old software interface. replaced with ISoftwareVersion
// check to see if we still need this.
export interface ISoftware {
id: number;
name: string; // e.g., "Figma.app"
version: string; // e.g., "2.1.11"
bundle_identifier?: string | null; // e.g., "com.figma.Desktop"
UI – Add VPP features for iPadOS and iOS (#20755) ## Addresses #20467 – part 2 ### Aggregate software: #### Software titles <img width="1616" alt="sw-titles-updated" src="https://github.com/user-attachments/assets/0b9922c7-e36e-4d2f-b204-95c3cdf9b602"> #### Software versions <img width="1616" alt="Screenshot 2024-07-29 at 6 14 21 PM" src="https://github.com/user-attachments/assets/5a097700-cd6c-45b1-a21f-9d76a733f0ae"> #### Host software <img width="1616" alt="Screenshot 2024-07-29 at 6 23 01 PM" src="https://github.com/user-attachments/assets/84e18695-f47a-4022-bd53-7f5d37ce452a"> ### Add software modal (VPP) _screenshots use mocked data - UI is flexible enough to display cleanly before and after backend is in place:_ <img width="1339" alt="happy" src="https://github.com/user-attachments/assets/8900aa93-316c-4a09-8e5a-1a1e45b0c458"> #### No apps: <img width="1572" alt="Screenshot 2024-07-29 at 6 35 03 PM" src="https://github.com/user-attachments/assets/466b9b6c-4d3d-49dd-94a9-94e395d89cb7"> #### Not enabled: <img width="1572" alt="Screenshot 2024-07-29 at 6 37 45 PM" src="https://github.com/user-attachments/assets/9bcfd480-8741-4d95-ba3b-550dee4dc673"> #### Error: <img width="1572" alt="Screenshot 2024-07-29 at 6 39 39 PM" src="https://github.com/user-attachments/assets/e944dd40-676e-4aba-9cd9-49ff319bf402"> ### Vuln support – Not supported for now: _see above screenshots for `list` endpoints_ #### Software title detail <img width="1616" alt="Screenshot 2024-07-29 at 6 47 29 PM" src="https://github.com/user-attachments/assets/2e30fd0a-21e4-4d19-bf9b-71a994bfd0e7"> #### Software version and OS detail: <img width="1616" alt="Screenshot 2024-07-29 at 6 48 28 PM" src="https://github.com/user-attachments/assets/e8fec769-ba97-4b6b-b10c-9bb4c973c732"> <img width="1616" alt="Screenshot 2024-07-29 at 6 50 25 PM" src="https://github.com/user-attachments/assets/0ac15727-e0cb-447c-8758-c58b79656d1a"> - [x] Changes file added for user-visible changes in `changes/`, - [x] Added/updated tests - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-07-30 17:14:25 +00:00
source: string; // "apps" | "ipados_apps" | "ios_apps" | "programs" | ?
generated_cpe: string;
vulnerabilities: ISoftwareVulnerability[] | null;
hosts_count?: number;
last_opened_at?: string | null; // e.g., "2021-08-18T15:11:35Z”
installed_paths?: string[];
browser?: string;
vendor?: string;
}
export type IVulnerabilitySoftware = Omit<ISoftware, "vulnerabilities"> & {
resolved_in_version: string;
};
export interface ISoftwareTitleVersion {
id: number;
version: string;
vulnerabilities: string[] | null; // TODO: does this return null or is it omitted?
hosts_count?: number;
}
export interface ISoftwarePackage {
name: string;
version: string;
uploaded_at: string;
install_script: string;
pre_install_query?: string;
post_install_script?: string;
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: boolean;
icon_url: string | null;
status: {
installed: number;
pending: number;
failed: number;
};
}
export const isSoftwarePackage = (
data: ISoftwarePackage | IAppStoreApp
): data is ISoftwarePackage =>
(data as ISoftwarePackage).install_script !== undefined;
export interface IAppStoreApp {
name: string;
app_store_id: number;
latest_version: string;
icon_url: string;
self_service: boolean;
status: {
installed: number;
pending: number;
failed: number;
};
}
export interface ISoftwareTitle {
id: number;
name: string;
versions_count: number;
source: string; // "apps" | "ios_apps" | "ipados_apps" | ?
hosts_count: number;
versions: ISoftwareTitleVersion[] | null;
software_package: ISoftwarePackage | null;
app_store_app: IAppStoreApp | null;
browser?: string;
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
}
export interface ISoftwareTitleDetails {
id: number;
name: string;
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
software_package: ISoftwarePackage | null;
app_store_app: IAppStoreApp | null;
source: string; // "apps" | "ios_apps" | "ipados_apps" | ?
hosts_count: number;
versions: ISoftwareTitleVersion[] | null;
versions_updated_at?: string;
bundle_identifier?: string;
browser?: string;
versions_count?: number;
}
export interface ISoftwareVulnerability {
cve: string;
details_link: string;
cvss_score?: number | null;
epss_probability?: number | null;
cisa_known_exploit?: boolean | null;
cve_published?: string | null;
cve_description?: string | null;
resolved_in_version?: string | null;
created_at?: string | null;
}
export interface ISoftwareVersion {
id: number;
name: string; // e.g., "Figma.app"
version: string; // e.g., "2.1.11"
bundle_identifier?: string; // e.g., "com.figma.Desktop"
source: string; // "apps" | "ipados_apps" | "ios_apps" | ?
browser: string; // e.g., "chrome"
release: string; // TODO: on software/verions/:id?
vendor: string;
arch: string; // e.g., "x86_64" // TODO: on software/verions/:id?
generated_cpe: string;
vulnerabilities: ISoftwareVulnerability[] | null;
hosts_count?: number;
}
export const SOURCE_TYPE_CONVERSION: Record<string, string> = {
apt_sources: "Package (APT)",
deb_packages: "Package (deb)",
portage_packages: "Package (Portage)",
rpm_packages: "Package (RPM)",
yum_sources: "Package (YUM)",
npm_packages: "Package (NPM)",
2023-12-04 19:26:26 +00:00
atom_packages: "Package (Atom)", // Atom packages were removed from software inventory. Mapping is maintained for backwards compatibility. (2023-12-04)
python_packages: "Package (Python)",
apps: "Application (macOS)",
UI – Add VPP features for iPadOS and iOS (#20755) ## Addresses #20467 – part 2 ### Aggregate software: #### Software titles <img width="1616" alt="sw-titles-updated" src="https://github.com/user-attachments/assets/0b9922c7-e36e-4d2f-b204-95c3cdf9b602"> #### Software versions <img width="1616" alt="Screenshot 2024-07-29 at 6 14 21 PM" src="https://github.com/user-attachments/assets/5a097700-cd6c-45b1-a21f-9d76a733f0ae"> #### Host software <img width="1616" alt="Screenshot 2024-07-29 at 6 23 01 PM" src="https://github.com/user-attachments/assets/84e18695-f47a-4022-bd53-7f5d37ce452a"> ### Add software modal (VPP) _screenshots use mocked data - UI is flexible enough to display cleanly before and after backend is in place:_ <img width="1339" alt="happy" src="https://github.com/user-attachments/assets/8900aa93-316c-4a09-8e5a-1a1e45b0c458"> #### No apps: <img width="1572" alt="Screenshot 2024-07-29 at 6 35 03 PM" src="https://github.com/user-attachments/assets/466b9b6c-4d3d-49dd-94a9-94e395d89cb7"> #### Not enabled: <img width="1572" alt="Screenshot 2024-07-29 at 6 37 45 PM" src="https://github.com/user-attachments/assets/9bcfd480-8741-4d95-ba3b-550dee4dc673"> #### Error: <img width="1572" alt="Screenshot 2024-07-29 at 6 39 39 PM" src="https://github.com/user-attachments/assets/e944dd40-676e-4aba-9cd9-49ff319bf402"> ### Vuln support – Not supported for now: _see above screenshots for `list` endpoints_ #### Software title detail <img width="1616" alt="Screenshot 2024-07-29 at 6 47 29 PM" src="https://github.com/user-attachments/assets/2e30fd0a-21e4-4d19-bf9b-71a994bfd0e7"> #### Software version and OS detail: <img width="1616" alt="Screenshot 2024-07-29 at 6 48 28 PM" src="https://github.com/user-attachments/assets/e8fec769-ba97-4b6b-b10c-9bb4c973c732"> <img width="1616" alt="Screenshot 2024-07-29 at 6 50 25 PM" src="https://github.com/user-attachments/assets/0ac15727-e0cb-447c-8758-c58b79656d1a"> - [x] Changes file added for user-visible changes in `changes/`, - [x] Added/updated tests - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
2024-07-30 17:14:25 +00:00
ios_apps: "Application (iOS)",
ipados_apps: "Application (iPadOS)",
chrome_extensions: "Browser plugin", // chrome_extensions can include any chrome-based browser (e.g., edge), so we rely instead on the `browser` field computed by Fleet server and fallback to this value if it is not present.
firefox_addons: "Browser plugin (Firefox)",
safari_extensions: "Browser plugin (Safari)",
homebrew_packages: "Package (Homebrew)",
programs: "Program (Windows)",
ie_extensions: "Browser plugin (IE)",
chocolatey_packages: "Package (Chocolatey)",
pkg_packages: "Package (pkg)",
vscode_extensions: "IDE extension (VS Code)",
2022-06-08 19:01:38 +00:00
} as const;
const BROWSER_TYPE_CONVERSION: Record<string, string> = {
chrome: "Chrome",
chromium: "Chromium",
opera: "Opera",
yandex: "Yandex",
brave: "Brave",
edge: "Edge",
edge_beta: "Edge Beta",
} as const;
export const formatSoftwareType = ({
source,
browser,
}: {
source: string;
browser?: string;
}) => {
let type = SOURCE_TYPE_CONVERSION[source] || "Unknown";
if (browser) {
type = `Browser plugin (${
BROWSER_TYPE_CONVERSION[browser] || startCase(browser)
})`;
}
return type;
};
/**
* This list comprises all possible states of software install operations.
*/
export const SOFTWARE_INSTALL_STATUSES = [
"failed",
2024-09-04 21:46:48 +00:00
"failed_install",
"installed",
"pending",
2024-09-04 21:46:48 +00:00
"pending_install",
2024-09-05 19:20:36 +00:00
"pending_uninstall",
"failed_uninstall",
] as const;
/*
* SoftwareInstallStatus represents the possible states of software install operations.
*/
export type SoftwareInstallStatus = typeof SOFTWARE_INSTALL_STATUSES[number];
export const isValidSoftwareInstallStatus = (
s: string | undefined
): s is SoftwareInstallStatus =>
!!s && SOFTWARE_INSTALL_STATUSES.includes(s as SoftwareInstallStatus);
/**
* ISoftwareInstallResult is the shape of a software install result object
* returned by the Fleet API.
*/
export interface ISoftwareInstallResult {
install_uuid: string;
software_title: string;
software_title_id: number;
software_package: string;
host_id: number;
host_display_name: string;
status: SoftwareInstallStatus;
detail: string;
output: string;
pre_install_query_output: string;
post_install_script_output: string;
}
export interface ISoftwareInstallResults {
results: ISoftwareInstallResult;
}
// ISoftwareInstallerType defines the supported installer types for
// software uploaded by the IT admin.
export type ISoftwareInstallerType = "pkg" | "msi" | "deb" | "exe";
export interface ISoftwareLastInstall {
install_uuid: string;
installed_at: string;
}
export interface IAppLastInstall {
command_uuid: string;
installed_at: string;
}
export interface ISoftwareInstallVersion {
version: string;
last_opened_at: string | null;
vulnerabilities: string[] | null;
installed_paths: string[];
}
export interface IHostSoftwarePackage {
name: string;
self_service: boolean;
icon_url: string;
version: string;
last_install: ISoftwareLastInstall | null;
}
export interface IHostAppStoreApp {
app_store_id: string;
self_service: boolean;
icon_url: string;
version: string;
last_install: IAppLastInstall | null;
}
export interface IHostSoftware {
id: number;
name: string;
software_package: IHostSoftwarePackage | null;
app_store_app: IHostAppStoreApp | null;
source: string;
bundle_identifier?: string;
status: SoftwareInstallStatus | null;
installed_versions: ISoftwareInstallVersion[] | null;
}
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
export type IDeviceSoftware = IHostSoftware;
2024-07-16 17:16:57 +00:00
const INSTALL_STATUS_PREDICATES: Record<SoftwareInstallStatus, string> = {
failed: "failed to install",
2024-09-04 21:46:48 +00:00
failed_install: "failed to install",
2024-07-16 17:16:57 +00:00
installed: "installed",
pending: "told Fleet to install",
2024-09-04 21:46:48 +00:00
pending_install: "told Fleet to install",
2024-09-05 19:20:36 +00:00
pending_uninstall: "told Fleet to uninstall",
failed_uninstall: "failed to uninstall",
2024-07-16 17:16:57 +00:00
} as const;
export const getInstallStatusPredicate = (status: string | undefined) => {
if (!status) {
return INSTALL_STATUS_PREDICATES.pending;
}
return (
INSTALL_STATUS_PREDICATES[status.toLowerCase() as SoftwareInstallStatus] ||
INSTALL_STATUS_PREDICATES.pending
);
};
export const INSTALL_STATUS_ICONS: Record<SoftwareInstallStatus, IconNames> = {
pending: "pending-outline",
2024-09-04 21:46:48 +00:00
pending_install: "pending-outline",
2024-07-16 17:16:57 +00:00
installed: "success-outline",
failed: "error-outline",
2024-09-04 21:46:48 +00:00
failed_install: "error-outline",
2024-09-05 19:20:36 +00:00
pending_uninstall: "pending-outline",
failed_uninstall: "error-outline",
2024-07-16 17:16:57 +00:00
} as const;
type IHostSoftwarePackageWithLastInstall = IHostSoftwarePackage & {
last_install: ISoftwareLastInstall;
};
export const hasHostSoftwarePackageLastInstall = (
software: IHostSoftware
): software is IHostSoftware & {
software_package: IHostSoftwarePackageWithLastInstall;
} => {
return !!software.software_package?.last_install;
};
type IHostAppWithLastInstall = IHostAppStoreApp & {
last_install: IAppLastInstall;
};
export const hasHostSoftwareAppLastInstall = (
software: IHostSoftware
): software is IHostSoftware & {
app_store_app: IHostAppWithLastInstall;
} => {
return !!software.app_store_app?.last_install;
};
export const isIpadOrIphoneSoftwareSource = (source: string) =>
["ios_apps", "ipados_apps"].includes(source);