Projects STRLCPY gradejs Commits 52183ebf
🤬
  • ■ ■ ■ ■ ■ ■
    packages/public-api/src/clientApiRouter.test.ts
    skipped 84 lines
    85 85   webPageScan.id.toString()
    86 86   );
    87 87   
    88  - const url = '/client/getWebPageScan?batch=1&input=' + encodeURIComponent(JSON.stringify({'0' : siteUrl}));
    89  - const responseGet = await api
    90  - .get(url)
    91  - .set('Origin', 'http://localhost:3000')
    92  - .expect(200);
    93  - expect(responseGet.body).toMatchObject([{
    94  - result: {
    95  - data: {
    96  - id: webPageScan.id.toString(),
    97  - status: WebPageScan.Status.Pending,
     88 + const url =
     89 + '/client/getWebPageScan?batch=1&input=' +
     90 + encodeURIComponent(JSON.stringify({ '0': siteUrl }));
     91 + const responseGet = await api.get(url).set('Origin', 'http://localhost:3000').expect(200);
     92 + expect(responseGet.body).toMatchObject([
     93 + {
     94 + result: {
     95 + data: {
     96 + id: webPageScan.id.toString(),
     97 + status: WebPageScan.Status.Pending,
     98 + },
    98 99   },
    99 100   },
    100  - }]);
     101 + ]);
    101 102   });
    102 103   
    103 104   it('should return a cached scan if applicable', async () => {
    skipped 29 lines
    133 134   
    134 135   expect(requestWebPageScanMock).toHaveBeenCalledTimes(0);
    135 136   
    136  - const url = '/client/getWebPageScan?batch=1&input=' + encodeURIComponent(JSON.stringify({'0' : siteUrl}));
    137  - const responseGet = await api
    138  - .get(url)
    139  - .set('Origin', 'http://localhost:3000')
    140  - .expect(200);
    141  - expect(responseGet.body).toMatchObject([{
    142  - result: {
    143  - data: {
    144  - id: existingScan.id.toString(),
    145  - status: WebPageScan.Status.Processed,
    146  - scanResult: {
    147  - identifiedModuleMap: {},
    148  - identifiedPackages: [
    149  - {
    150  - name: 'react',
    151  - versionSet: ['17.0.0'],
    152  - moduleIds: [],
    153  - },
    154  - ],
     137 + const url =
     138 + '/client/getWebPageScan?batch=1&input=' +
     139 + encodeURIComponent(JSON.stringify({ '0': siteUrl }));
     140 + const responseGet = await api.get(url).set('Origin', 'http://localhost:3000').expect(200);
     141 + expect(responseGet.body).toMatchObject([
     142 + {
     143 + result: {
     144 + data: {
     145 + id: existingScan.id.toString(),
     146 + status: WebPageScan.Status.Processed,
     147 + scanResult: {
     148 + identifiedModuleMap: {},
     149 + identifiedPackages: [
     150 + {
     151 + name: 'react',
     152 + versionSet: ['17.0.0'],
     153 + moduleIds: [],
     154 + },
     155 + ],
     156 + },
    155 157   },
    156 158   },
    157 159   },
    158  - }]);
     160 + ]);
    159 161   });
    160 162  });
    161 163   
  • ■ ■ ■ ■
    packages/public-api/src/clientApiRouter.ts
    skipped 63 lines
    64 64   async resolve({ input: url }) {
    65 65   const scan = await getWebPageScan(url);
    66 66   if (!scan) {
    67  - return { id: '', status: WebPageStatusNoData.NoData };
     67 + return null;
    68 68   }
    69 69   
    70 70   const scanResponse: RequestWebPageScanResponse = {
    skipped 41 lines
  • ■ ■ ■ ■ ■ ■
    packages/web/src/components/pages/WebsiteResults.tsx
    skipped 21 lines
    22 22   - Make up filters types, reenable filters
    23 23   */
    24 24   
    25  - const { vulnerabilities, keywordsList, status, vulnerabilitiesCount, lastScanDate } =
    26  - useAppSelector(selectors.default);
     25 + const { vulnerabilities, keywordsList, status, vulnerabilitiesCount } = useAppSelector(
     26 + selectors.default
     27 + );
    27 28   const packagesFiltered = useAppSelector(selectors.packagesSortedAndFiltered);
    28 29   const packagesStats = useAppSelector(selectors.packagesStats);
    29 30   const { isProtected, isPending, isLoading, isFailed, isInvalid } = useAppSelector(
    skipped 90 lines
    120 121   vulnerabilities={vulnerabilities ?? {}}
    121 122   vulnerabilitiesCount={vulnerabilitiesCount}
    122 123   keywordsList={keywordsList}
    123  - status={{ status, lastScanDate }}
     124 + status={status}
    124 125   />
    125 126   </>
    126 127   );
    skipped 2 lines
  • ■ ■ ■ ■ ■
    packages/web/src/store/selectors/websiteResults.ts
    skipped 39 lines
    40 40  });
    41 41  export type ScanStatus = ReturnType<typeof getScanStatus>;
    42 42   
    43  -const getPackagesMemoized = memoize((result: GetWebPageScanOutput['scanResult']) => {
     43 +const getPackagesMemoized = memoize((result: NonNullable<GetWebPageScanOutput>['scanResult']) => {
    44 44   const packages: IdentifiedPackage[] = (result?.identifiedPackages ?? []).map((pkg) => {
    45 45   return {
    46 46   ...pkg,
    skipped 94 lines
    141 141  export const selectors = {
    142 142   default: createSelector(
    143 143   [getScanStatus, getVulnerabilities, getKeywords],
    144  - ({ status, lastScanDate }, vulnerabilities, keywordsList) => ({
     144 + (status, vulnerabilities, keywordsList) => ({
    145 145   status,
    146  - lastScanDate,
    147 146   vulnerabilities,
    148 147   keywordsList,
    149 148   vulnerabilitiesCount: new Set(
    skipped 28 lines
  • ■ ■ ■ ■
    packages/web/src/store/slices/websiteResults.ts
    skipped 20 lines
    21 21   setTimeout(r, ms);
    22 22   });
    23 23   
    24  -const isScanPending = (result: GetWebPageScanOutput) => result.status === 'pending';
     24 +const isScanPending = (result: GetWebPageScanOutput) => result?.status === 'pending';
    25 25   
    26 26  const getScanResults = createAsyncThunk(
    27 27   'scanResults/getScanResults',
    skipped 57 lines
Please wait...
Page is in error, reload to recover