/** * Copyright (c) 2021 OpenLens Authors * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ import "./pod-security-policy-details.scss"; import React from "react"; import { observer } from "mobx-react"; import { DrawerItem, DrawerTitle } from "../drawer"; import type { KubeObjectDetailsProps } from "../kube-object"; import type { PodSecurityPolicy } from "../../api/endpoints"; import { Badge } from "../badge"; import { Table, TableCell, TableHead, TableRow } from "../table"; import { KubeObjectMeta } from "../kube-object/kube-object-meta"; import { kubeObjectDetailRegistry } from "../../api/kube-object-detail-registry"; interface Props extends KubeObjectDetailsProps { } @observer export class PodSecurityPolicyDetails extends React.Component { renderRuleGroup( title: React.ReactNode, group: { rule: string; ranges?: { max: number; min: number }[]; }) { if (!group) return null; const { rule, ranges } = group; return ( <> {rule} {ranges && ( {ranges.map(({ min, max }, index) => { return ; })} )} ); } render() { const { object: psp } = this.props; if (!psp) { return null; } const { allowedHostPaths, allowedCapabilities, allowedCSIDrivers, allowedFlexVolumes, allowedProcMountTypes, allowedUnsafeSysctls, allowPrivilegeEscalation, defaultAddCapabilities, forbiddenSysctls, fsGroup, hostIPC, hostNetwork, hostPID, hostPorts, privileged, readOnlyRootFilesystem, requiredDropCapabilities, runAsGroup, runAsUser, runtimeClass, seLinux, supplementalGroups, volumes, } = psp.spec; return (
{allowedCapabilities && ( {allowedCapabilities.join(", ")} )} {volumes && ( {volumes.join(", ")} )} {allowedCSIDrivers && ( {allowedCSIDrivers.map(({ name }) => name).join(", ")} )} {allowedFlexVolumes && ( {allowedFlexVolumes.map(({ driver }) => driver).join(", ")} )} {allowedProcMountTypes && ( {allowedProcMountTypes.join(", ")} )} {allowedUnsafeSysctls && ( {allowedUnsafeSysctls.join(", ")} )} {forbiddenSysctls && ( {forbiddenSysctls.join(", ")} )} {allowPrivilegeEscalation ? "Yes" : "No"} {privileged ? "Yes" : "No"} {readOnlyRootFilesystem ? "Yes" : "No"} {defaultAddCapabilities && ( {defaultAddCapabilities.join(", ")} )} {requiredDropCapabilities && ( {requiredDropCapabilities.join(", ")} )} {hostIPC ? "Yes" : "No"} {hostNetwork ? "Yes" : "No"} {hostPID ? "Yes" : "No"} {hostPorts && ( {hostPorts.map(({ min, max }, index) => { return ; })} )} {allowedHostPaths && ( <> Path Prefix Read-only {allowedHostPaths.map(({ pathPrefix, readOnly }, index) => { return ( {pathPrefix} {readOnly ? "Yes" : "No"} ); })}
)} {this.renderRuleGroup("Fs Group", fsGroup)} {this.renderRuleGroup("Run As Group", runAsGroup)} {this.renderRuleGroup("Run As User", runAsUser)} {this.renderRuleGroup("Supplemental Groups", supplementalGroups)} {runtimeClass && ( <> {(runtimeClass.allowedRuntimeClassNames || []).join(", ") || "-"} {runtimeClass.defaultRuntimeClassName || "-"} )} {seLinux && ( <> {seLinux.rule} {seLinux.seLinuxOptions && ( <> {seLinux.seLinuxOptions.level} {seLinux.seLinuxOptions.role} {seLinux.seLinuxOptions.type} {seLinux.seLinuxOptions.user} )} )}
); } } kubeObjectDetailRegistry.add({ kind: "PodSecurityPolicy", apiVersions: ["policy/v1beta1"], components: { Details: (props) => } });