fleet/frontend/interfaces/software.ts
Jacob Shandling faa65ac350
UI: Add column for published date to Vulnerabilities table (#10656)
## Addresses #9834 
<img width="1215" alt="added date to vuln table"
src="https://user-images.githubusercontent.com/61553566/226730586-4165f5c9-2a42-4378-b58b-7900838a8707.png">

## Checklist for submitter

If some of the following don't apply, delete the relevant line.

- [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>
2023-03-23 09:32:32 -07:00

62 lines
1.8 KiB
TypeScript

import PropTypes from "prop-types";
import vulnerabilityInterface, { IVulnerability } 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;
}
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"
source: string; // e.g., "apps"
generated_cpe: string;
vulnerabilities: IVulnerability[] | null;
hosts_count?: number;
last_opened_at?: string | null; // e.g., "2021-08-18T15:11:35Z”
}
export const 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)",
atom_packages: "Package (Atom)",
python_packages: "Package (Python)",
apps: "Application (macOS)",
chrome_extensions: "Browser plugin (Chrome)",
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)",
} as const;
export const formatSoftwareType = (source: string): string => {
const DICT = TYPE_CONVERSION;
return DICT[source] || "Unknown";
};