faker icon indicating copy to clipboard operation
faker copied to clipboard

feat(security): new module

Open thisislawatts opened this issue 2 years ago • 14 comments

Introduces a security module which allows users to generate one of the following:

These are a few of the broadly supported standards which have seen adoption by the security community. Although there are a few emerging alternatives as well.

I do not believe that any localisation is needed for these but happy to do some further research but thought I'd share the work as it stands and see if it seemed interesting to anyone else.

thisislawatts avatar Jul 13 '22 21:07 thisislawatts

Codecov Report

Merging #1151 (a3945eb) into main (5bdba8b) will increase coverage by 0.00%. The diff coverage is 97.67%.

:exclamation: Current head a3945eb differs from pull request most recent head f4b2053. Consider uploading reports for the commit f4b2053 to get more accurate results

@@           Coverage Diff            @@
##             main    #1151    +/-   ##
========================================
  Coverage   99.62%   99.62%            
========================================
  Files        2163     2165     +2     
  Lines      241264   240858   -406     
  Branches     1013     1031    +18     
========================================
- Hits       240356   239954   -402     
+ Misses        887      883     -4     
  Partials       21       21            
Impacted Files Coverage Δ
src/modules/security/index.ts 97.41% <97.41%> (ø)
src/faker.ts 100.00% <100.00%> (ø)
src/internal/toDate.ts 100.00% <100.00%> (ø)
src/modules/date/index.ts 99.01% <100.00%> (-0.09%) :arrow_down:
src/modules/datatype/index.ts 96.03% <0.00%> (-0.22%) :arrow_down:
src/modules/helpers/index.ts 98.43% <0.00%> (-0.08%) :arrow_down:
src/modules/random/index.ts 97.63% <0.00%> (-0.06%) :arrow_down:
src/modules/color/index.ts 99.71% <0.00%> (-0.03%) :arrow_down:
src/modules/address/index.ts 99.81% <0.00%> (-0.02%) :arrow_down:
... and 22 more

codecov[bot] avatar Jul 14 '22 01:07 codecov[bot]

Thanks @ST-DDT and @Shinigami92 both for taking the time to review the work here so far. ✨

thisislawatts avatar Aug 09 '22 05:08 thisislawatts

@ST-DDT Can I get approval for these workflows to run and see how it fairs?

thisislawatts avatar Aug 31 '22 16:08 thisislawatts

Investigating:

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  test/scripts/apidoc/examplesAndDeprecations.spec.ts > examples and deprecations > Security > cve
Error: Transform failed with 1 error:
 ❯ failureErrorWithLog node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1624:15
/home/runner/work/faker/faker/test/scripts/apidoc/temp/Security/cve.ts:3:83: ERROR: Expected "}" but found ")"
 ❯ node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1413:29
 ❯ node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:678:9
 ❯ handleIncomingPacket node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:775:9
 ❯ Socket.readFromStdout node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:644:7
 ❯ Socket.emit node:events:513:28

thisislawatts avatar Aug 31 '22 17:08 thisislawatts

Docs Preview

Click to expand

grafik

ST-DDT avatar Sep 02 '22 16:09 ST-DDT

Please also run pnpm run docs:dev once.

ST-DDT avatar Sep 02 '22 16:09 ST-DDT

Please also run pnpm run docs:dev once.

I've run this locally but seeing some breakages, which seem unexpected?

When attempting to load the API overview: Screenshot 2022-09-08 at 08 33 28

Output when running: pnpm run generate:api-docs

warning <internal>.CallSite.getTypeName: Comment [[target]] style links are deprecated and will be removed in 0.24
warning Failed to find target: Class
JSON written to ./docs/api/typedoc.json
/Users/luke/oss/faker/scripts/apidoc/moduleMethods.ts:19
    .getChildrenByKind(ReflectionKind.Module)[0]
                                              ^

TypeError: Cannot read properties of undefined (reading 'getChildrenByKind')
    at selectApiModules (/Users/luke/oss/faker/scripts/apidoc/moduleMethods.ts:19:47)
    at null.processModuleMethods (/Users/luke/oss/faker/scripts/apidoc/moduleMethods.ts:34:24)
    at null.build (/Users/luke/oss/faker/scripts/apidoc.ts:38:24)

Also seeing the same behaviour when running the main branch, so something odd in my local environment.

Node: v16.16.0 pnpm: 7.9.5

thisislawatts avatar Sep 08 '22 06:09 thisislawatts

Have you installed the latest dependencies pnpm install?

ST-DDT avatar Sep 08 '22 06:09 ST-DDT

@ST-DDT, I believe so.

$ pnpm install
Lockfile is up to date, resolution step is skipped
Already up to date

thisislawatts avatar Sep 08 '22 12:09 thisislawatts

If you are fine with it. I will have a look later and update the branch.

ST-DDT avatar Sep 08 '22 12:09 ST-DDT

Thanks @ST-DDT ✨ I will squash the commits once @Shinigami92 has had a chance to re-review.

thisislawatts avatar Sep 09 '22 17:09 thisislawatts

All methods now need a @since 8.0.0

ST-DDT avatar Sep 09 '22 22:09 ST-DDT

All methods now need a @since 8.0.0

@ST-DDT Doesn't this kind of depend on the module getting user interest? I can see that introducing a @since property to each doc block is, an outstanding task before the work is mergeable but seems impossible to know exactly what release version this would land in.

thisislawatts avatar Sep 10 '22 07:09 thisislawatts

The @since is needed to pass the tests. Sure the version might needs to be changed later/before merging, but at least it is visible. If the test fail, the PR is less likely to be reviewed and reacted to.

ST-DDT avatar Sep 10 '22 08:09 ST-DDT