Skip to content

Commit

Permalink
Merge branch 'main' into release-2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanan-ravi committed Jul 30, 2024
2 parents 674662a + 86d6644 commit 48988dc
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const ScanHistoryDropdown = ({
scan.onDownloadClick(scan.id);
setOpen(false);
}}
data-testid="menuDownloadIconId"
/>
<IconButton
variant="flat"
Expand All @@ -97,6 +98,7 @@ export const ScanHistoryDropdown = ({
scan.onDeleteClick(scan.id);
setOpen(false);
}}
data-testid="menuDeleteIconId"
/>

<IconButton
Expand All @@ -116,6 +118,7 @@ export const ScanHistoryDropdown = ({
scan?.onScanTimeCompareButtonClick?.(scan.timestamp);
setOpen(false);
}}
data-testid="menuCompareIconId"
/>
</div>
</div>
Expand All @@ -125,7 +128,10 @@ export const ScanHistoryDropdown = ({
</>
}
>
<span className="text-h5 flex items-center text-text-input-value gap-x-2">
<span
className="text-h5 flex items-center text-text-input-value gap-x-2"
data-testid="scanHistoryDropdownId"
>
{currentTimeStamp}
<div className="h-4 w-4 text-accent-accent">
<CaretDown />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,20 @@ export const CardHeader = ({
const Wrapper = ({ children }: { children: ReactNode }) => {
if (link?.length) {
return (
<DFLink
to={link}
unstyled
className="p-3 flex items-center text-text-text-and-icon hover:text-accent-accent border-b dark:border-df-gray-900 border-bg-grid-border"
<div
className="p-3 flex items-center text-text-text-and-icon border-b dark:border-df-gray-900 border-bg-grid-border"
data-testid={`${title}Id`}
>
<span className="flex-1 truncate flex items-center gap-2">{children}</span>
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end">
<CaretDown />
</div>
</DFLink>
<DFLink to={link}>
<div className="text-p4 leading-0 flex gap-x-1 items-center">
More
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end -mr-1 hover:underline">
<CaretDown />
</div>
</div>
</DFLink>
</div>
);
}
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1538,17 +1538,6 @@ const MalwareTable = ({
size: 160,
maxSize: 165,
}),
columnHelper.accessor('resources', {
enableSorting: false,
enableResizing: true,
cell: (info) => {
return <TruncatedText text={info.getValue()?.join(', ') ?? ''} />;
},
header: () => <TruncatedText text="Affected resources" />,
minSize: 180,
size: 180,
maxSize: 190,
}),
columnHelper.accessor('summary', {
enableSorting: false,
enableResizing: true,
Expand Down Expand Up @@ -1780,7 +1769,7 @@ const ScanResults = () => {
</div>
{filtersExpanded ? <Filters /> : null}
<div className="dark:shadow-none shadow-md">
<Suspense fallback={<TableSkeleton columns={7} rows={10} />}>
<Suspense fallback={<TableSkeleton columns={8} rows={10} />}>
<MalwareTable
onTableAction={onTableAction}
setShowDeleteDialog={setShowDeleteDialog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReactNode } from 'react';

import { DFLink } from '@/components/DFLink';
import { CaretDown } from '@/components/icons/common/CaretDown';
import { TruncatedText } from '@/components/TruncatedText';

export const CardHeader = ({
icon,
Expand All @@ -13,16 +14,17 @@ export const CardHeader = ({
path: string;
}) => {
return (
<DFLink to={path} unstyled>
<div className="flex items-center gap-2 text-text-text-and-icon hover:text-accent-accent border-b dark:border-df-gray-900 border-bg-grid-border px-2 py-3">
<span className="h-4 w-4 shrink-0">{icon}</span>
<span className="text-t2 uppercase truncate flex-1" title={title}>
{title}
</span>
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end">
<CaretDown />
<div className="flex items-center gap-2 text-text-text-and-icon border-b dark:border-df-gray-900 border-bg-grid-border px-2 py-3">
<span className="h-4 w-4 shrink-0">{icon}</span>
<TruncatedText className="text-t2 uppercase truncate flex-1" text={title} />
<DFLink to={path}>
<div className="text-p4 leading-0 flex gap-x-1 items-center">
More
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end -mr-1 hover:underline">
<CaretDown />
</div>
</div>
</div>
</DFLink>
</DFLink>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ const HistoryControls = () => {
nodeType: nodeType as UtilsReportFiltersNodeTypeEnum,
});
}}
data-testid="downloadScanButtonId"
>
Download
</Button>
Expand All @@ -236,6 +237,7 @@ const HistoryControls = () => {
}
disabled={fetchStatus !== 'idle'}
onClick={() => setScanIdToDelete(scan_id ?? '')}
data-testid="deleteScanButtonId"
>
Delete
</Button>
Expand All @@ -256,6 +258,7 @@ const HistoryControls = () => {
showScanTimeModal: true,
});
}}
data-testid="compareScanButtonId"
>
Compare scan
</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReactNode } from 'react';

import { DFLink } from '@/components/DFLink';
import { CaretDown } from '@/components/icons/common/CaretDown';
import { TruncatedText } from '@/components/TruncatedText';

export const CardHeader = ({
icon,
Expand All @@ -13,16 +14,17 @@ export const CardHeader = ({
path: string;
}) => {
return (
<DFLink to={path} unstyled>
<div className="flex items-center gap-2 text-text-text-and-icon hover:text-accent-accent border-b dark:border-df-gray-900 border-bg-grid-border px-2 py-3">
<span className="h-4 w-4 shrink-0">{icon}</span>
<span className="text-t2 uppercase truncate flex-1" title={title}>
{title}
</span>
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end">
<CaretDown />
<div className="flex items-center gap-2 text-text-text-and-icon border-b dark:border-df-gray-900 border-bg-grid-border px-2 py-3">
<span className="h-4 w-4 shrink-0">{icon}</span>
<TruncatedText className="text-t2 uppercase truncate flex-1" text={title} />
<DFLink to={path}>
<div className="text-p4 leading-0 flex gap-x-1 items-center">
More
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end -mr-1 hover:underline">
<CaretDown />
</div>
</div>
</div>
</DFLink>
</DFLink>
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -1489,23 +1489,23 @@ const SecretTable = ({
</DFLink>
),
header: () => 'Name',
minSize: 80,
size: 100,
maxSize: 130,
minSize: 100,
size: 120,
maxSize: 150,
}),
columnHelper.accessor('full_filename', {
cell: (info) => <TruncatedText text={info.getValue()} />,
header: () => <TruncatedText text="File name" />,
minSize: 100,
size: 110,
size: 120,
maxSize: 140,
}),
columnHelper.accessor('matched_content', {
cell: (info) => <TruncatedText text={info.getValue()} />,
header: () => 'Matched content',
minSize: 130,
size: 140,
maxSize: 165,
size: 150,
maxSize: 170,
}),
columnHelper.accessor('level', {
cell: (info) => (
Expand All @@ -1518,20 +1518,9 @@ const SecretTable = ({
</div>
),
header: () => 'Severity',
minSize: 30,
size: 50,
maxSize: 70,
}),
columnHelper.accessor('resources', {
enableSorting: false,
enableResizing: true,
cell: (info) => {
return <TruncatedText text={info.getValue()?.join(', ') ?? ''} />;
},
header: () => <TruncatedText text="Affected resources" />,
minSize: 100,
size: 120,
maxSize: 190,
minSize: 60,
size: 80,
maxSize: 100,
}),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ReactNode } from 'react';

import { DFLink } from '@/components/DFLink';
import { CaretDown } from '@/components/icons/common/CaretDown';
import { TruncatedText } from '@/components/TruncatedText';

export const CardHeader = ({
icon,
Expand All @@ -13,16 +14,17 @@ export const CardHeader = ({
path: string;
}) => {
return (
<DFLink to={path} unstyled>
<div className="flex items-center gap-2 text-text-text-and-icon hover:text-accent-accent border-b dark:border-df-gray-900 border-bg-grid-border px-2 py-3">
<span className="h-4 w-4 shrink-0">{icon}</span>
<span className="text-t2 uppercase truncate flex-1" title={title}>
{title}
</span>
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end">
<CaretDown />
<div className="flex items-center gap-2 text-text-text-and-icon border-b dark:border-df-gray-900 border-bg-grid-border px-2 py-3">
<span className="h-4 w-4 shrink-0">{icon}</span>
<TruncatedText className="text-t2 uppercase truncate flex-1" text={title} />
<DFLink to={path}>
<div className="text-p4 leading-0 flex gap-x-1 items-center">
More
<div className="h-4 w-4 shrink-0 -rotate-90 justify-self-end -mr-1 hover:underline">
<CaretDown />
</div>
</div>
</div>
</DFLink>
</DFLink>
</div>
);
};
26 changes: 13 additions & 13 deletions deepfence_worker/tasks/reports/pdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ var (
)

var colors = map[string]*props.Color{
"alarm": &props.Color{Red: 228, Green: 29, Blue: 75},
"info": &props.Color{Red: 29, Green: 142, Blue: 230},
"ok": &props.Color{Red: 21, Green: 183, Blue: 126},
"skip": &props.Color{Red: 156, Green: 163, Blue: 175},
"pass": &props.Color{Red: 21, Green: 183, Blue: 126},
"warn": &props.Color{Red: 255, Green: 156, Blue: 50},
"note": &props.Color{Red: 156, Green: 163, Blue: 175},
"delete": &props.Color{Red: 224, Green: 81, Blue: 109},
"critical": &props.Color{Red: 245, Green: 102, Blue: 130},
"high": &props.Color{Red: 255, Green: 124, Blue: 2},
"medium": &props.Color{Red: 255, Green: 156, Blue: 50},
"low": &props.Color{Red: 229, Green: 195, Blue: 84},
"": &props.Color{Red: 156, Green: 163, Blue: 175},
"alarm": {Red: 228, Green: 29, Blue: 75},
"info": {Red: 29, Green: 142, Blue: 230},
"ok": {Red: 21, Green: 183, Blue: 126},
"skip": {Red: 156, Green: 163, Blue: 175},
"pass": {Red: 21, Green: 183, Blue: 126},
"warn": {Red: 255, Green: 156, Blue: 50},
"note": {Red: 156, Green: 163, Blue: 175},
"delete": {Red: 224, Green: 81, Blue: 109},
"critical": {Red: 245, Green: 102, Blue: 130},
"high": {Red: 255, Green: 124, Blue: 2},
"medium": {Red: 255, Green: 156, Blue: 50},
"low": {Red: 229, Green: 195, Blue: 84},
"": {Red: 156, Green: 163, Blue: 175},
}

func truncateText(s string, max int) string {
Expand Down
2 changes: 1 addition & 1 deletion deepfence_worker/tasks/reports/pdf_cloud_compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func cloudcompliancePDF(ctx context.Context, params utils.ReportParams) (core.Do
resultRows = append(
resultRows,
row.New(18).Add(
text.NewCol(1, strconv.Itoa(k),
text.NewCol(1, strconv.Itoa(k+1),
props.Text{Size: 10, Top: 1, Align: align.Center}).
WithStyle(cellStyle),
text.NewCol(5, v.Resource,
Expand Down
4 changes: 2 additions & 2 deletions deepfence_worker/tasks/reports/pdf_compliance.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func compliancePDF(ctx context.Context, params utils.ReportParams) (core.Documen
resultRows = append(
resultRows,
row.New(15).Add(
text.NewCol(1, strconv.Itoa(k),
text.NewCol(1, strconv.Itoa(k+1),
props.Text{Size: 10, Top: 1, Align: align.Center}).
WithStyle(cellStyle),
text.NewCol(1, v.Status,
Expand All @@ -191,7 +191,7 @@ func compliancePDF(ctx context.Context, params utils.ReportParams) (core.Documen
resultRows = append(
resultRows,
row.New(15).Add(
text.NewCol(1, strconv.Itoa(k),
text.NewCol(1, strconv.Itoa(k+1),
props.Text{Size: 10, Top: 1, Align: align.Center}).
WithStyle(cellStyle),
text.NewCol(1, v.Status,
Expand Down
2 changes: 1 addition & 1 deletion deepfence_worker/tasks/reports/pdf_malware.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func malwarePDF(ctx context.Context, params utils.ReportParams) (core.Document,
resultRows = append(
resultRows,
row.New(15).Add(
text.NewCol(1, strconv.Itoa(k),
text.NewCol(1, strconv.Itoa(k+1),
props.Text{Size: 10, Top: 1, Align: align.Center}).
WithStyle(cellStyle),
text.NewCol(2, v.RuleName,
Expand Down
2 changes: 1 addition & 1 deletion deepfence_worker/tasks/reports/pdf_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func secretPDF(ctx context.Context, params utils.ReportParams) (core.Document, e
resultRows = append(
resultRows,
row.New(15).Add(
text.NewCol(1, strconv.Itoa(k),
text.NewCol(1, strconv.Itoa(k+1),
props.Text{Size: 10, Top: 1, Align: align.Center}).
WithStyle(cellStyle),
text.NewCol(2, v.Name,
Expand Down
4 changes: 2 additions & 2 deletions deepfence_worker/tasks/reports/pdf_vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func vulnerabilityPDF(ctx context.Context, params utils.ReportParams) (core.Docu
resultRows = append(
resultRows,
row.New(15).Add(
text.NewCol(1, strconv.Itoa(k),
text.NewCol(1, strconv.Itoa(k+1),
props.Text{Size: 10, Top: 1, Align: align.Center}).
WithStyle(cellStyle),
text.NewCol(2, v.CveID,
Expand All @@ -104,7 +104,7 @@ func vulnerabilityPDF(ctx context.Context, params utils.ReportParams) (core.Docu
props.Text{Size: 10, Left: 1, Top: 1, BreakLineStrategy: breakline.EmptySpaceStrategy}).
WithStyle(cellStyle),
text.NewCol(1, "link",
props.Text{Size: 10, Top: 1, Align: align.Center, Hyperlink: &v.CveLink}).
props.Text{Size: 10, Top: 1, Align: align.Center, Hyperlink: &d.ScanResults[k].CveLink}).
WithStyle(cellStyle),
),
)
Expand Down
16 changes: 9 additions & 7 deletions deepfence_worker/tasks/reports/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,17 @@ func sbomReport(ctx context.Context, params utils.ReportParams) (string, error)
return "", err
}

// check if conversion in required
var newSBOMContent []byte
if strings.HasPrefix(sbomFormat, "syft-json") {
// SBOM already in syft-json format
return saveSbomToFile(sbomContent, params)
}

newSBOMContent, err := convertSBOMFormat(bytes.NewReader(sbomContent), sbomFormat)
if err != nil {
log.Error().Err(err).Msgf("error converting sbom to %s", sbomFormat)
return "", err
newSBOMContent = sbomContent
} else {
newSBOMContent, err = convertSBOMFormat(bytes.NewReader(sbomContent), sbomFormat)
if err != nil {
log.Error().Err(err).Msgf("error converting sbom to %s", sbomFormat)
return "", err
}
}

// compress sbom
Expand Down
Loading

0 comments on commit 48988dc

Please sign in to comment.