diff --git a/CHANGELOG.md b/CHANGELOG.md
index fbfb351ee..4b5047e65 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -440,4 +440,12 @@ Remove facilitated testing page Remove facilitated testing page https://github.c
* Code Quality: Add E2E tests for extension and CLI https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/773
* Chore: Make NPM commands used for development uniform. https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/775
* Bump “fast-xml-parser” from 4.4.0 to 4.4.1 https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/790
-* Chore: Setup report package development configurations https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/756
\ No newline at end of file
+* Chore: Setup report package development configurations https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/756
+
+
+#v0.10.1
+
+# Changelog
+
+## Extension
+- Fix: Miscellaneous QA issues https://github.com/GoogleChromeLabs/ps-analysis-tool/pull/795
\ No newline at end of file
diff --git a/bin/chrome-3pcd-ps.bat b/bin/chrome-3pcd-ps.bat
index 38a135ae5..d76e584b3 100644
--- a/bin/chrome-3pcd-ps.bat
+++ b/bin/chrome-3pcd-ps.bat
@@ -1,7 +1,7 @@
:: Chrome 3pcd with PS Extension
:: Download PS Extension
-set "ps_analysis_tool_version=v0.10.0"
+set "ps_analysis_tool_version=v0.10.1"
cd /d %TEMP%
if not exist %TEMP%\ps-analysis-tool-%ps_analysis_tool_version% (
mkdir %TEMP%\ps-analysis-tool-%ps_analysis_tool_version%
diff --git a/bin/chrome-default-ps.bat b/bin/chrome-default-ps.bat
index c38022a4a..9f21d6715 100644
--- a/bin/chrome-default-ps.bat
+++ b/bin/chrome-default-ps.bat
@@ -1,7 +1,7 @@
:: Default Chrome with PS Extension
:: Download PS Extension
-set "ps_analysis_tool_version=v0.10.0"
+set "ps_analysis_tool_version=v0.10.1"
cd /d %TEMP%
if not exist %TEMP%\ps-analysis-tool-%ps_analysis_tool_version% (
mkdir %TEMP%\ps-analysis-tool-%ps_analysis_tool_version%
diff --git a/bin/chrome_launcher.sh b/bin/chrome_launcher.sh
index 4bf896d3d..d43dc811f 100644
--- a/bin/chrome_launcher.sh
+++ b/bin/chrome_launcher.sh
@@ -2,7 +2,7 @@
# Download Extension
extension_setup() {
- ps_analysis_tool_version=v0.10.0
+ ps_analysis_tool_version=v0.10.1
extension_dir="/var/tmp"
cd $extension_dir
if [ ! -d $extension_dir/ps-analysis-tool-$ps_analysis_tool_version ]; then
diff --git a/docs/development-workflows.md b/docs/development-workflows.md
index 6e78761d8..95ff168ea 100644
--- a/docs/development-workflows.md
+++ b/docs/development-workflows.md
@@ -41,7 +41,7 @@ npm run dev:cli
After making changes in the `cli`, `cli-dashboard`, or any CLI-related packages, use:
```bash
-npm run build:cli
+npm run build:cli:dashboard
```
## Build Workflows
diff --git a/package-lock.json b/package-lock.json
index da22f0b22..84b3c53c7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "ps-analysis-tool",
- "version": "0.10.0",
+ "version": "0.10.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "ps-analysis-tool",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"workspaces": [
"packages/*"
@@ -22339,7 +22339,7 @@
},
"packages/analysis-utils": {
"name": "@google-psat/analysis-utils",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/common": "*",
@@ -22366,7 +22366,7 @@
},
"packages/cli": {
"name": "@google-psat/cli",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/analysis-utils": "*",
@@ -22398,7 +22398,7 @@
},
"packages/cli-dashboard": {
"name": "@google-psat/cli-dashboard",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/common": "*",
@@ -22444,7 +22444,7 @@
},
"packages/common": {
"name": "@google-psat/common",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/i18n": "*",
@@ -22461,7 +22461,7 @@
},
"packages/design-system": {
"name": "@google-psat/design-system",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/common": "*",
@@ -22479,7 +22479,7 @@
},
"packages/eslint-import-resolver": {
"name": "@google-psat/eslint-import-resolver",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"eslint-import-resolver-node": "^0.3.7"
@@ -22487,7 +22487,7 @@
},
"packages/extension": {
"name": "@google-psat/extension",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@floating-ui/core": "^1.5.0",
@@ -22527,7 +22527,7 @@
},
"packages/i18n": {
"name": "@google-psat/i18n",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"intl-messageformat": "^10.5.11"
@@ -22535,7 +22535,7 @@
},
"packages/library-detection": {
"name": "@google-psat/library-detection",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/common": "*",
@@ -22560,7 +22560,7 @@
},
"packages/report": {
"name": "@google-psat/report",
- "version": "0.10.0",
+ "version": "0.10.1",
"license": "Apache-2.0",
"dependencies": {
"@google-psat/common": "*",
diff --git a/package.json b/package.json
index a3811621c..03b994cdf 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "ps-analysis-tool",
- "version": "0.10.0",
+ "version": "0.10.1",
"description": "Cookie Analysis Tool and CLI for analysis and understanding of cookie usage on web pages.",
"scripts": {
"build-storybook": "storybook build",
diff --git a/packages/analysis-utils/package.json b/packages/analysis-utils/package.json
index dd101d5c0..49598914a 100644
--- a/packages/analysis-utils/package.json
+++ b/packages/analysis-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "@google-psat/analysis-utils",
- "version": "0.10.0",
+ "version": "0.10.1",
"description": "A package for CLI analysis",
"main": "dist/index.js",
"types": "dist-types/index.d.ts",
diff --git a/packages/analysis-utils/src/browserManagement/index.ts b/packages/analysis-utils/src/browserManagement/index.ts
index e0b12366d..e24d30aac 100644
--- a/packages/analysis-utils/src/browserManagement/index.ts
+++ b/packages/analysis-utils/src/browserManagement/index.ts
@@ -334,7 +334,7 @@ export class BrowserManagement {
domain: parsedCookie.domain,
path: parsedCookie.path || '/',
value: parsedCookie.value,
- samesite: parsedCookie.samesite || 'Lax',
+ samesite: parsedCookie.samesite?.toLowerCase() || 'lax',
expires: parsedCookie.expires || 'Session',
httponly: parsedCookie.httponly || false,
secure: parsedCookie.secure || false,
@@ -407,9 +407,9 @@ export class BrowserManagement {
domain: associatedCookie.cookie.domain,
path: associatedCookie.cookie.path || '/',
value: associatedCookie.cookie.value,
- sameSite: associatedCookie.cookie.sameSite || 'Lax',
+ samesite: associatedCookie.cookie.sameSite?.toLowerCase() || 'lax',
expires: associatedCookie.cookie.expires || 'Session',
- httpOnly: associatedCookie.cookie.httpOnly || false,
+ httponly: associatedCookie.cookie.httpOnly || false,
secure: associatedCookie.cookie.secure || false,
partitionKey: '',
},
@@ -562,7 +562,12 @@ export class BrowserManagement {
}
const key = cookie.name + ':' + cookie.domain + ':' + cookie.path;
frameCookies[key] = {
- parsedCookie: { ...cookie, partitionKey: '' },
+ parsedCookie: {
+ ...cookie,
+ partitionKey: '',
+ httponly: false,
+ samesite: cookie.sameSite?.toLowerCase() || 'lax',
+ },
};
});
diff --git a/packages/analysis-utils/src/types.ts b/packages/analysis-utils/src/types.ts
index be4d567e2..1ab5025aa 100644
--- a/packages/analysis-utils/src/types.ts
+++ b/packages/analysis-utils/src/types.ts
@@ -56,7 +56,7 @@ export interface CookieLogDetails
category: string;
description: string;
isFirstParty: 'Yes' | 'No';
- sameSite: string;
+ samesite: string;
partitionKey?: Protocol.Network.CookiePartitionKey;
pageUrl: string;
requestUrls: { [key: string]: string };
diff --git a/packages/cli-dashboard/package.json b/packages/cli-dashboard/package.json
index 7323ae2ab..f5d10d4e1 100644
--- a/packages/cli-dashboard/package.json
+++ b/packages/cli-dashboard/package.json
@@ -1,6 +1,6 @@
{
"name": "@google-psat/cli-dashboard",
- "version": "0.10.0",
+ "version": "0.10.1",
"description": "Dashboard for visualizing cli analysis output",
"author": {
"name": "Google"
diff --git a/packages/cli-dashboard/src/app.tsx b/packages/cli-dashboard/src/app.tsx
index 99148307b..c0cb12fd5 100644
--- a/packages/cli-dashboard/src/app.tsx
+++ b/packages/cli-dashboard/src/app.tsx
@@ -60,6 +60,10 @@ const App = () => {
return;
}
+ if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
+ bodyTag.classList.add('dark');
+ }
+
bodyTag.style.fontSize = '75%';
}, []);
@@ -130,7 +134,7 @@ const App = () => {
}
return (
-
+
{
const spinnies = new Spinnies();
spinnies.add('error-line-1', {
diff --git a/packages/cli/src/utils/index.ts b/packages/cli/src/utils/index.ts
index a9113f1eb..7502f218b 100644
--- a/packages/cli/src/utils/index.ts
+++ b/packages/cli/src/utils/index.ts
@@ -21,5 +21,5 @@ export { default as getUrlsFromSitemap } from './getUrlListFromArgs';
export { default as askUserInput } from './askUserInput';
export { default as generatePrefix } from './generatePrefix';
export { default as getOutputFilePath } from './getOutputFilePath';
-export { default as saveResultAsHTML } from './saveResultAsHTML';
+export { default as saveResultsAsHTML } from './saveResultAsHTML';
export * from './validators';
diff --git a/packages/cli/src/utils/saveReports.ts b/packages/cli/src/utils/saveReports.ts
index 4f18a4004..0e13694e7 100644
--- a/packages/cli/src/utils/saveReports.ts
+++ b/packages/cli/src/utils/saveReports.ts
@@ -23,8 +23,8 @@ import { ensureFile, writeFile } from 'fs-extra';
* Internal dependencies.
*/
import generateCSVFiles from './generateCSVfiles';
-import path from 'path';
-import { saveResultAsHTML } from '.';
+import path, { basename } from 'path';
+import saveResultsAsHTML from './saveResultAsHTML';
const getFolderName = (pageUrl: string) => {
let folderName = pageUrl
@@ -46,7 +46,14 @@ const saveReports = async (
sitemapUrl: string
) => {
if (result.length > 1) {
- await saveResultAsHTML(outDir, result, true, 'report.html', sitemapUrl);
+ await saveResultsAsHTML(
+ outDir,
+ result,
+ true,
+ sitemapUrl ? new URL(sitemapUrl).hostname : basename(outDir),
+ 'report.html',
+ sitemapUrl
+ );
// Sitemap report
await Promise.all(
result.map(async (siteReport) => {
@@ -63,10 +70,11 @@ const saveReports = async (
await writeFile(path.join(fileDir, 'cookies.csv'), allCookiesCSV);
await ensureFile(path.join(fileDir, 'report.html'));
- await saveResultAsHTML(
+ await saveResultsAsHTML(
fileDir,
[siteReport],
false,
+ new URL(siteReport.pageUrl).hostname,
'report.html',
sitemapUrl
);
@@ -101,7 +109,13 @@ const saveReports = async (
await writeFile(path.join(outDir, 'cookies.csv'), allCookiesCSV);
await ensureFile(path.join(outDir, 'report.html'));
- await saveResultAsHTML(outDir, [result[0]], false, 'report.html');
+ await saveResultsAsHTML(
+ outDir,
+ [result[0]],
+ false,
+ new URL(result[0].pageUrl).hostname,
+ 'report.html'
+ );
if (technologyDataCSV) {
await ensureFile(path.join(outDir, 'technologies.csv'));
diff --git a/packages/cli/src/utils/saveResultAsHTML.ts b/packages/cli/src/utils/saveResultAsHTML.ts
index c16a6bee2..e2b6ab8cb 100644
--- a/packages/cli/src/utils/saveResultAsHTML.ts
+++ b/packages/cli/src/utils/saveResultAsHTML.ts
@@ -35,6 +35,7 @@ const isProduction = process.env.NODE_ENV === 'production';
* @param outDir The path to the output.
* @param result The completeJSON of the output.
* @param isSiteMap Whether the output is sitemap of not
+ * @param selectedSiteName Selected site name to be used for exporting cookies.
* @param fileName Optional filename to use used for the output file.
* @param sitemapUrl Sitemap URL
*/
@@ -42,6 +43,7 @@ const saveResultsAsHTML = async (
outDir: string,
result: CompleteJson[],
isSiteMap: boolean,
+ selectedSiteName: string,
fileName?: string | null,
sitemapUrl?: string | undefined
) => {
@@ -99,7 +101,7 @@ const saveResultsAsHTML = async (
window.PSAT_DATA = ${JSON.stringify({
json: result,
type: isSiteMap ? 'sitemap' : 'url',
- selectedSite: outDir?.trim()?.slice(6) ?? '',
+ selectedSite: selectedSiteName,
translations: messages,
dateTime,
siteMapUrl: isSiteMap ? sitemapUrl : '',
diff --git a/packages/common/package.json b/packages/common/package.json
index 435137b61..d9f567426 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -1,6 +1,6 @@
{
"name": "@google-psat/common",
- "version": "0.10.0",
+ "version": "0.10.1",
"description": "A package for common utilities that are being used in multiple packages",
"main": "dist/index.js",
"types": "dist-types/index.d.ts",
diff --git a/packages/common/src/cookies.types.ts b/packages/common/src/cookies.types.ts
index a3c9de1a6..be414ac03 100644
--- a/packages/common/src/cookies.types.ts
+++ b/packages/common/src/cookies.types.ts
@@ -203,9 +203,9 @@ export type CookieJsonDataType = {
partitionKey: string;
path: string;
expires: string;
- httpOnly: boolean;
+ httponly: boolean;
secure: boolean;
- sameSite: string;
+ samesite: string;
priority?: 'Low' | 'Medium' | 'High';
size?: number;
};
diff --git a/packages/common/src/utils/findAnalyticsMatch.ts b/packages/common/src/utils/findAnalyticsMatch.ts
index 0f8cbc229..e1d7a31d5 100644
--- a/packages/common/src/utils/findAnalyticsMatch.ts
+++ b/packages/common/src/utils/findAnalyticsMatch.ts
@@ -34,7 +34,7 @@ const wildTest = (wildcard: string, str: string): boolean => {
};
export const emptyAnalytics = {
- platform: '',
+ platform: 'Unknown',
category: 'Uncategorized',
name: '',
domain: '',
@@ -44,7 +44,7 @@ export const emptyAnalytics = {
gdprUrl: '',
wildcard: '',
};
-
+const STATIC_CATEGORIES = ['Functional', 'Marketing', 'Analytics'];
/**
* Finds analytics in cookie DB for a cookie name.
* @param {string} key cookie name to be matched.
@@ -70,7 +70,9 @@ const findAnalyticsMatch = (
}
});
- analytics.category = analytics.category || 'Uncategorized';
+ analytics.category = STATIC_CATEGORIES.includes(analytics.category ?? '')
+ ? analytics.category
+ : 'Uncategorized';
return analytics;
};
diff --git a/packages/common/src/utils/generateReports/generateAllCookiesCSV.ts b/packages/common/src/utils/generateReports/generateAllCookiesCSV.ts
index 117d3b382..718406a1b 100644
--- a/packages/common/src/utils/generateReports/generateAllCookiesCSV.ts
+++ b/packages/common/src/utils/generateReports/generateAllCookiesCSV.ts
@@ -17,16 +17,17 @@
/**
* External dependencies
*/
-import sanitizeCsvRecord from '../sanitizeCsvRecord';
import { I18n } from '@google-psat/i18n';
/**
* Internal dependencies
*/
import {
+ CookieTableData,
type CompleteJson,
type CookieJsonDataType,
} from '../../cookies.types';
-import calculateEffectiveExpiryDate from '../calculateEffectiveExpiryDate';
+import generateExtensionCookieTableCSV from './generateExtensionCookietableCSV';
+import generateCLICookieTableCSV from './generateCLICookieTableCSV';
export const COOKIES_DATA_HEADER = [
() => I18n.getMessage('name'),
@@ -59,61 +60,19 @@ const generateAllCookiesCSV = (siteAnalysisData: CompleteJson): string => {
});
});
- if (isExtension) {
- COOKIES_DATA_HEADER.push(
- () => I18n.getMessage('priority'),
- () => I18n.getMessage('size')
- );
- }
-
- let cookieRecords = '';
+ const cookieRecords: CookieTableData[] = [];
for (const cookie of cookieMap.values()) {
- //This should be in the same order as cookieDataHeader
- const expires = calculateEffectiveExpiryDate(cookie.parsedCookie.expires);
-
- const recordsArray = [
- cookie.parsedCookie.name,
- cookie.isFirstParty
- ? I18n.getMessage('firstParty')
- : I18n.getMessage('thirdParty'),
- cookie.parsedCookie.domain || ' ',
- cookie.parsedCookie.partitionKey || ' ',
- cookie.parsedCookie.sameSite,
- I18n.getMessage(
- cookie.analytics?.category?.toLowerCase() || 'uncategorized'
- ),
- cookie.analytics.platform,
- cookie.parsedCookie.httpOnly
- ? I18n.getMessage('yes')
- : I18n.getMessage('no'),
- cookie.parsedCookie.secure
- ? I18n.getMessage('yes')
- : I18n.getMessage('no'),
- cookie.parsedCookie.value,
- cookie.parsedCookie.path,
- expires === 'Session' ? I18n.getMessage('session') : expires,
- cookie.isBlocked ? I18n.getMessage('yes') : I18n.getMessage('no'),
- cookie.analytics.GDPR || 'NA',
- ];
-
- if (isExtension) {
- recordsArray.push(
- I18n.getMessage((cookie.parsedCookie?.priority || ' ').toLowerCase()),
- cookie.parsedCookie?.size?.toString() ?? ' '
- );
- }
-
- recordsArray.map(sanitizeCsvRecord);
-
- cookieRecords += recordsArray.join(',') + '\r\n';
+ //@ts-ignore
+ cookieRecords.push(cookie);
+ }
+ if (isExtension) {
+ return generateExtensionCookieTableCSV(cookieRecords, true) as string;
+ } else {
+ return generateCLICookieTableCSV(cookieRecords, true) as string;
}
- return (
- COOKIES_DATA_HEADER.map((header) => header()).join(',') +
- '\r\n' +
- cookieRecords
- );
+ return '';
};
export default generateAllCookiesCSV;
diff --git a/packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts b/packages/common/src/utils/generateReports/generateCLICookieTableCSV.ts
similarity index 82%
rename from packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts
rename to packages/common/src/utils/generateReports/generateCLICookieTableCSV.ts
index f8b386167..ebdfce65a 100644
--- a/packages/design-system/src/components/table/utils/generateCLICookieTableCSV.ts
+++ b/packages/common/src/utils/generateReports/generateCLICookieTableCSV.ts
@@ -16,8 +16,12 @@
/**
* External dependencies.
*/
-import { type CookieTableData, sanitizeCsvRecord } from '@google-psat/common';
import { I18n } from '@google-psat/i18n';
+/**
+ * Internal dependencies.
+ */
+import sanitizeCsvRecord from '../sanitizeCsvRecord';
+import { type CookieTableData } from '../../cookies.types';
const COOKIES_TABLE_DATA_HEADER_CLI = [
() => I18n.getMessage('name'),
@@ -36,7 +40,10 @@ const COOKIES_TABLE_DATA_HEADER_CLI = [
() => I18n.getMessage('gdpr'),
];
-const generateCLICookieTableCSV = (cookies: CookieTableData[]): Blob => {
+const generateCLICookieTableCSV = (
+ cookies: CookieTableData[],
+ returnString = false
+): Blob | string => {
let cookieRecords = '';
for (const cookie of cookies) {
@@ -48,8 +55,7 @@ const generateCLICookieTableCSV = (cookies: CookieTableData[]): Blob => {
: I18n.getMessage('thirdParty'),
cookie.parsedCookie.domain || ' ',
cookie.parsedCookie.partitionKey || ' ',
- //@ts-ignore
- cookie.parsedCookie?.sameSite ?? cookie.parsedCookie?.samesite,
+ I18n.getMessage((cookie.parsedCookie?.samesite ?? 'lax').toLowerCase()),
I18n.getMessage(
cookie.analytics?.category?.toLowerCase() || 'uncategorized'
),
@@ -70,6 +76,14 @@ const generateCLICookieTableCSV = (cookies: CookieTableData[]): Blob => {
cookieRecords += recordsArray.join(',') + '\r\n';
}
+ if (returnString) {
+ return (
+ COOKIES_TABLE_DATA_HEADER_CLI.map((header) => header()).join(',') +
+ '\r\n' +
+ cookieRecords
+ );
+ }
+
return new Blob([
COOKIES_TABLE_DATA_HEADER_CLI.map((header) => header()).join(',') +
'\r\n' +
diff --git a/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts b/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts
index fa5c5ef30..dddab4556 100644
--- a/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts
+++ b/packages/common/src/utils/generateReports/generateCookiesWithIssuesCSV.ts
@@ -78,12 +78,12 @@ const generateCookiesWithIssuesCSV = (
: I18n.getMessage('thirdParty'),
cookie.parsedCookie.domain || ' ',
cookie.parsedCookie.partitionKey || ' ',
- cookie.parsedCookie.sameSite,
+ I18n.getMessage((cookie.parsedCookie.samesite ?? 'lax').toLowerCase()),
I18n.getMessage(
cookie.analytics?.category?.toLowerCase() || 'uncategorized'
),
cookie.analytics.platform,
- cookie.parsedCookie.httpOnly
+ cookie.parsedCookie.httponly
? I18n.getMessage('yes')
: I18n.getMessage('no'),
cookie.parsedCookie.secure
diff --git a/packages/design-system/src/components/table/utils/generatExtensionCookietableCSV.ts b/packages/common/src/utils/generateReports/generateExtensionCookietableCSV.ts
similarity index 84%
rename from packages/design-system/src/components/table/utils/generatExtensionCookietableCSV.ts
rename to packages/common/src/utils/generateReports/generateExtensionCookietableCSV.ts
index 945379372..9b6683e10 100644
--- a/packages/design-system/src/components/table/utils/generatExtensionCookietableCSV.ts
+++ b/packages/common/src/utils/generateReports/generateExtensionCookietableCSV.ts
@@ -16,8 +16,12 @@
/**
* External dependencies.
*/
-import { type CookieTableData, sanitizeCsvRecord } from '@google-psat/common';
import { I18n } from '@google-psat/i18n';
+/**
+ * Internal dependencies.
+ */
+import sanitizeCsvRecord from '../sanitizeCsvRecord';
+import { type CookieTableData } from '../../cookies.types';
const COOKIES_TABLE_DATA_HEADER_EXTENSION = [
() => I18n.getMessage('name'),
@@ -38,7 +42,10 @@ const COOKIES_TABLE_DATA_HEADER_EXTENSION = [
() => I18n.getMessage('size'),
];
-const generateExtensionCookieTableCSV = (cookies: CookieTableData[]): Blob => {
+const generateExtensionCookieTableCSV = (
+ cookies: CookieTableData[],
+ returnString = false
+): Blob | string => {
let cookieRecords = '';
for (const cookie of cookies) {
@@ -50,7 +57,7 @@ const generateExtensionCookieTableCSV = (cookies: CookieTableData[]): Blob => {
: I18n.getMessage('thirdParty'),
cookie.parsedCookie.domain || ' ',
cookie.parsedCookie.partitionKey || ' ',
- cookie.parsedCookie.samesite,
+ I18n.getMessage((cookie.parsedCookie.samesite ?? 'lax').toLowerCase()),
I18n.getMessage(
cookie.analytics?.category?.toLowerCase() || 'uncategorized'
),
@@ -75,6 +82,14 @@ const generateExtensionCookieTableCSV = (cookies: CookieTableData[]): Blob => {
cookieRecords += recordsArray.join(',') + '\r\n';
}
+ if (returnString) {
+ return (
+ COOKIES_TABLE_DATA_HEADER_EXTENSION.map((header) => header()).join(',') +
+ '\r\n' +
+ cookieRecords
+ );
+ }
+
return new Blob([
COOKIES_TABLE_DATA_HEADER_EXTENSION.map((header) => header()).join(',') +
'\r\n' +
diff --git a/packages/common/src/utils/generateReports/index.ts b/packages/common/src/utils/generateReports/index.ts
index 75a64d39b..d4c377694 100644
--- a/packages/common/src/utils/generateReports/index.ts
+++ b/packages/common/src/utils/generateReports/index.ts
@@ -18,3 +18,5 @@ export { default as generateCookiesWithIssuesCSV } from './generateCookiesWithIs
export { default as generateAllCookiesCSV } from './generateAllCookiesCSV';
export { default as generateSummaryDataCSV } from './generateSummaryDataCSV';
export { default as generateTechnologyCSV } from './generateTechnologyCSV';
+export { default as generateCLICookieTableCSV } from './generateCLICookieTableCSV';
+export { default as generateExtensionCookieTableCSV } from './generateExtensionCookietableCSV';
diff --git a/packages/common/src/utils/parseRequestWillBeSentExtraInfo.ts b/packages/common/src/utils/parseRequestWillBeSentExtraInfo.ts
index 072d04d3a..c74ea54ef 100644
--- a/packages/common/src/utils/parseRequestWillBeSentExtraInfo.ts
+++ b/packages/common/src/utils/parseRequestWillBeSentExtraInfo.ts
@@ -71,7 +71,7 @@ export default function parseRequestWillBeSentExtraInfo(
...cookieWithoutPartitionKey,
httponly: cookieWithoutPartitionKey?.httpOnly ?? false,
expires: effectiveExpirationDate,
- samesite: cookie.sameSite?.toLowerCase() ?? '',
+ samesite: cookie.sameSite?.toLowerCase() ?? 'lax',
domain,
partitionKey: '',
},
diff --git a/packages/common/src/utils/parseResponseReceivedExtraInfo.ts b/packages/common/src/utils/parseResponseReceivedExtraInfo.ts
index a04442f1a..04bc69d0a 100644
--- a/packages/common/src/utils/parseResponseReceivedExtraInfo.ts
+++ b/packages/common/src/utils/parseResponseReceivedExtraInfo.ts
@@ -96,7 +96,10 @@ export default function parseResponseReceivedExtraInfo(
...parsedCookie,
httponly: parsedCookie?.httponly ?? false,
expires: effectiveExpirationDate,
- samesite: parsedCookie.samesite ?? '',
+ samesite:
+ parsedCookie.samesite !== ''
+ ? parsedCookie.samesite?.toLowerCase()
+ : 'lax',
domain,
partitionKey: '',
},
diff --git a/packages/common/src/utils/sanitizeCsvRecord.ts b/packages/common/src/utils/sanitizeCsvRecord.ts
index 9e07add3b..c6e676d39 100644
--- a/packages/common/src/utils/sanitizeCsvRecord.ts
+++ b/packages/common/src/utils/sanitizeCsvRecord.ts
@@ -31,7 +31,9 @@ const sanitizeCsvRecord = (record: unknown): string => {
}
recordCopy = recordCopy.replace(/"/g, '""');
- return recordCopy.includes(',') ? '"' + recordCopy + '"' : recordCopy;
+ return recordCopy.includes(',') || recordCopy.includes('"')
+ ? '"' + recordCopy + '"'
+ : recordCopy;
};
export default sanitizeCsvRecord;
diff --git a/packages/common/src/utils/tests/sanitizeCsvRecords.ts b/packages/common/src/utils/tests/sanitizeCsvRecords.ts
index cbd85fe5f..7e0dc2d08 100644
--- a/packages/common/src/utils/tests/sanitizeCsvRecords.ts
+++ b/packages/common/src/utils/tests/sanitizeCsvRecords.ts
@@ -33,7 +33,7 @@ describe('sanitizeCsvRecord : ', () => {
it('should add double quotes before any double quotes in the string', () => {
const invalidString = 'a value with "quotes"';
- const validString = 'a value with ""quotes""';
+ const validString = '"a value with ""quotes"""';
expect(sanitizeCsvRecord(invalidString)).toBe(validString);
});
diff --git a/packages/design-system/package.json b/packages/design-system/package.json
index b42dcc53f..811fac6b5 100644
--- a/packages/design-system/package.json
+++ b/packages/design-system/package.json
@@ -1,6 +1,6 @@
{
"name": "@google-psat/design-system",
- "version": "0.10.0",
+ "version": "0.10.1",
"description": "A package for presentational components that are being used in multiple packages",
"main": "dist/index.js",
"types": "dist-types/index.d.ts",
diff --git a/packages/design-system/src/components/circlePieChart/emptyCirclePieChart.tsx b/packages/design-system/src/components/circlePieChart/emptyCirclePieChart.tsx
index efc8faa66..48919547d 100644
--- a/packages/design-system/src/components/circlePieChart/emptyCirclePieChart.tsx
+++ b/packages/design-system/src/components/circlePieChart/emptyCirclePieChart.tsx
@@ -32,7 +32,7 @@ const EmptyCirclePieChart = () => {
colorScale={[COLOR_MAP.brightGray.color]}
data={[{ x: '', y: 100 }]}
/>
-
+
0
diff --git a/packages/design-system/src/components/circlePieChart/index.tsx b/packages/design-system/src/components/circlePieChart/index.tsx
index 403617cf2..b9600c89a 100644
--- a/packages/design-system/src/components/circlePieChart/index.tsx
+++ b/packages/design-system/src/components/circlePieChart/index.tsx
@@ -56,7 +56,6 @@ const CirclePieChart = ({
({ x: '', y: count }))}
labels={() => ''}
colorScale={data.map(({ color }) => color)}
diff --git a/packages/design-system/src/components/cookieTable/utils/exportCookies.ts b/packages/design-system/src/components/cookieTable/utils/exportCookies.ts
index 137d18b02..4bd3ed48f 100644
--- a/packages/design-system/src/components/cookieTable/utils/exportCookies.ts
+++ b/packages/design-system/src/components/cookieTable/utils/exportCookies.ts
@@ -20,6 +20,8 @@
import {
type CookieTableData,
getCurrentDateAndTime,
+ generateCLICookieTableCSV,
+ generateExtensionCookieTableCSV,
} from '@google-psat/common';
import { saveAs } from 'file-saver';
@@ -27,10 +29,6 @@ import { saveAs } from 'file-saver';
* Internal dependencies
*/
import { TableRow } from '../../table';
-import {
- generateCLICookieTableCSV,
- generateExtensionCookieTableCSV,
-} from '../../table/utils';
const exportCookies = (isCLI = false, rows: TableRow[], hostname: string) => {
const _cookies = rows.map(({ originalData }) => originalData);
diff --git a/packages/design-system/src/components/cookiesLanding/landingHeader/index.tsx b/packages/design-system/src/components/cookiesLanding/landingHeader/index.tsx
index b4cc5510b..a5317152a 100644
--- a/packages/design-system/src/components/cookiesLanding/landingHeader/index.tsx
+++ b/packages/design-system/src/components/cookiesLanding/landingHeader/index.tsx
@@ -43,10 +43,10 @@ const LandingHeader = ({
)}
data-testid="cookies-landing-header"
>
-
+
{dataMapping.map((circleData, index) => {
return (
-
+