Skip to content

Commit 5b89a52

Browse files
authored
Merge pull request #799 from l3montree-dev/fix/quickfixes
fix: created a two-line view
2 parents 888fcf8 + a98a2bd commit 5b89a52

1 file changed

Lines changed: 33 additions & 23 deletions

File tree

src/components/Quickfix.tsx

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ export const DiffHighlighter: FunctionComponent<DiffHighlighterProps> = ({
2424
return <span className="font-mono text-xs">{oldVersionPurl}</span>;
2525
}
2626

27-
const { name, version } = PackageURL.fromString(oldVersionPurl);
27+
const { namespace, name, version } = PackageURL.fromString(oldVersionPurl);
28+
const fullName = namespace ? `${namespace}/${name}` : name;
2829

2930
if (newVersionPurl && isValidPackagePurl(newVersionPurl)) {
3031
const { version: newVer } = PackageURL.fromString(newVersionPurl);
31-
const differences = diffChars(name + "@" + version, name + "@" + newVer);
32+
const differences = diffChars(
33+
fullName + "@" + version,
34+
fullName + "@" + newVer,
35+
);
3236

3337
return (
3438
<div className="font-mono text-xs">
@@ -64,8 +68,10 @@ function renderQuickFixText(
6468
switch (type) {
6569
case "npm":
6670
return `npm install ${fullName}@${version}`;
67-
case "golang":
68-
return `go get ${fullName}@v${version}`;
71+
case "golang": {
72+
const goVersion = version?.startsWith("v") ? version : `v${version}`;
73+
return `go get ${fullName}@${goVersion}`;
74+
}
6975
case "pypi":
7076
return `pip install ${fullName}==${version}`;
7177
case "cargo":
@@ -138,25 +144,29 @@ const Quickfix: FunctionComponent<{ vuln: DetailedDependencyVulnDTO }> = ({
138144
>
139145
Resolve Vulnerability
140146
</Badge>
141-
<div className="flex flex-row gap-1 items-center">
142-
<span>Fix the vulnerability </span>
143-
<span className="font-semibold">{vuln.cveID}</span>
144-
<span> by upgrading from: </span>
145-
<span className="flex flex-row gap-2">
146-
<Badge className="font-mono" variant={"outline"}>
147-
{purlToDisplayString(vulnerabilityPath)}
148-
</Badge>
149-
<ArrowRight className="w-4" />
150-
<Badge
151-
variant={"outline"}
152-
className="font-mono scale-100 relative border-2"
153-
>
154-
<DiffHighlighter
155-
oldVersionPurl={vulnerabilityPath}
156-
newVersionPurl={fixedVersionPurl ?? ""}
157-
/>
158-
</Badge>
159-
</span>
147+
<div className="flex flex-col gap-1 items-left">
148+
<div className="flex flex-row gap-1">
149+
<span>Fix the vulnerability </span>
150+
<span className="font-semibold">{vuln.cveID}</span>
151+
</div>
152+
<div className="flex flex-row gap-1">
153+
<span> by upgrading from: </span>
154+
<span className="flex flex-row gap-2">
155+
<Badge className="font-mono" variant={"outline"}>
156+
{purlToDisplayString(vulnerabilityPath)}
157+
</Badge>
158+
<ArrowRight className="w-4" />
159+
<Badge
160+
variant={"outline"}
161+
className="font-mono scale-100 relative border-2"
162+
>
163+
<DiffHighlighter
164+
oldVersionPurl={vulnerabilityPath}
165+
newVersionPurl={fixedVersionPurl ?? ""}
166+
/>
167+
</Badge>
168+
</span>
169+
</div>
160170
</div>
161171
<div className="mt-2 flex">
162172
<CopyCode codeString={ecosystemUpdate} language="shell" />

0 commit comments

Comments
 (0)