From 52d2e367dcf214acc674a7e67eae9cd68d49e4ed Mon Sep 17 00:00:00 2001 From: Neil Zhao Date: Thu, 29 Sep 2022 23:00:28 -0400 Subject: [PATCH] chore: update rule.md - small fixes. --- docs/rules.md | 46 ++++++++++++++++++++++------- rules/file-hashes-not-exist.js | 2 +- rules/file-not-contents-config.json | 2 +- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/docs/rules.md b/docs/rules.md index f325b1a4..fbe074f6 100644 --- a/docs/rules.md +++ b/docs/rules.md @@ -11,6 +11,7 @@ Below is a complete list of rules that Repolinter can run, along with their conf - [`file-contents`](#file-contents) - [`file-existence`](#file-existence) - [`file-hash`](#file-hash) + - [`file-hashes-not-exist`](#file-hashes-not-exist) - [`file-no-broken-links`](#file-no-broken-links) - [`file-not-contents`](#file-not-contents) - [`file-not-exists`](#file-not-exists) @@ -21,6 +22,7 @@ Below is a complete list of rules that Repolinter can run, along with their conf - [`git-list-tree`](#git-list-tree) - [`git-working-tree`](#git-working-tree) - [`json-schema-passes`](#json-schema-passes) + - [`large-file`](#large-file) - [`license-detectable-by-licensee`](#license-detectable-by-licensee) - [`best-practices-badge-present`](#best-practices-badge-present) @@ -76,13 +78,24 @@ Checks the existence of a given file. Checks that a given file matches a provided hash. | Input | Required | Type | Default | Description | -| ---------------------- | -------- | ---------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ---------------------- | -------- | ---------- | -------- |------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `globsAny` | **Yes** | `string[]` | | A list of globs to search for. This rule passes if at least one file found matches the provided hash, and fails if no files are found. | -| `hash` | **Yes** | `string` | | The hash to check against. Unless a different `algorithm` is specified, this will be sha256. | +| `hash` | **Yes** | `string` | | The hash to check against. Unless a different `algorithm` is specified, this will be sha256 hash. | | `algorithm` | No | `string` | `sha256` | The hash algorithm to use. Repolinter supports any algorithm supported by [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options) | | `nocase` | No | `boolean` | `false` | Set to `true` to perform an case insensitive search. | | `succeed-on-non-exist` | No | `boolean` | `false` | Set to `true` to enable passing if no files are found from `globsAll`. | +### `file-hashes-not-exist` + +Check files' hashes not included in a list of certain cryptographic hashes. + +| Input | Required | Type | Default | Description | +|------------------------| -------- |------------|----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `globsAll` | **Yes** | `string[]` | | A list of globs to search for. This rule passes if all of the markup files found do not contain broken links. | +| `hashes` | **Yes** | `string[]` | | The hashes to check against. Unless a different `algorithm` is specified, this will be sha256 hash. | +| `algorithm` | No | `string` | `sha256` | The hash algorithm to use. Repolinter supports any algorithm supported by [crypto.createHash](https://nodejs.org/api/crypto.html#crypto_crypto_createhash_algorithm_options) | +| `nocase` | No | `boolean` | `false` | Set to `true` to perform an case insensitive search. | + ### `file-no-broken-links` Scans a set of markup files for broken links. Links are tested by first rendering the markup file to HTML using [github-markup](https://github.com/github/markup), then each `` tag in the HTML is extracted and tested using [broken-link-checker](https://github.com/prototypicalpro/broken-link-checker)--as a result, this rule only supports checking markup formats supported by [github-markup](https://github.com/github/markup). Absolute URLs are checked using a HTTP request, and relative URLs are checked by accessing the file specified. @@ -101,14 +114,18 @@ Scans a set of markup files for broken links. Links are tested by first renderin Checks none of a given list of files match a given regular expression. -| Input | Required | Type | Default | Description | -| ------------------------ | -------- | ---------- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `globsAll` | **Yes** | `string[]` | | A list of globs to get files for. This rule passes if none of the files returned by the globs match the supplied string, or if no files are returned. | -| `content` | **Yes** | `string` | | The regular expression to check using `String#search`. This expression should not include the enclosing slashes and may need to be escaped to properly integrate with the JSON config (ex. `".+@.+\\..+"` for an email address). | -| `nocase` | No | `boolean` | `false` | Set to `true` to make the globs case insensitive. This does not effect the case sensitivity of the regular expression. | -| `flags` | No | `string` | `""` | The flags to use for the regular expression in `content` (ex. `"i"` for case insensitivity). | -| `human-readable-content` | No | `string` | The regular expression in `content` | The string to print instead of the regular expression when generating human-readable output. | -| `fail-on-non-existent` | No | `boolean` | `false` | Set to `true` to disable passing if no files are found from `globsAll`. | +Note: provide either `content` or `contents` + +| Input | Required | Type | Default | Description | +|--------------------------|------------------------------------|------------| ----------------------------------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `globsAll` | **Yes** | `string[]` | | A list of globs to get files for. This rule passes if none of the files returned by the globs match the supplied string, or if no files are returned. | +| `content` | **Yes** if `contents` is undefined | `string` | | The regular expression to check using `String#search`. This expression should not include the enclosing slashes and may need to be escaped to properly integrate with the JSON config (ex. `".+@.+\\..+"` for an email address). | +| `contents` | **Yes** if `content` is undefined | `string[]` | | Regular expressions to check using `String#search`. This expression should not include the enclosing slashes and may need to be escaped to properly integrate with the JSON config (ex. `".+@.+\\..+"` for an email address). | +| `nocase` | No | `boolean` | `false` | Set to `true` to make the globs case insensitive. This does not effect the case sensitivity of the regular expression. | +| `nocase` | No | `boolean` | `false` | Set to `true` to make the globs case insensitive. This does not effect the case sensitivity of the regular expression. | +| `flags` | No | `string` | `""` | The flags to use for the regular expression in `content` (ex. `"i"` for case insensitivity). | +| `human-readable-content` | No | `string` | The regular expression in `content` | The string to print instead of the regular expression when generating human-readable output. | +| `fail-on-non-existent` | No | `boolean` | `false` | Set to `true` to disable passing if no files are found from `globsAll`. | ### `file-not-exists` @@ -181,6 +198,15 @@ Checks whether the directory is managed with Git. | ------------- | -------- | --------- | ------- | ------------------------------------------------------------- | | `allowSubDir` | No | `boolean` | | Whether or not to search subdirectories for a git repository. | +### `large-file` + +Check if a list of files' size on the file system that is larger than provided size. + +| Input | Required | Type | Default | Description | +|--------------------------| -------- |------------| ---------------------- |------------------------------------------------------------------------------------------------------------------------------------------------------| +| `globsAll` | **Yes** | `string[]` | | A list of globs to get files for. This rule passes if all of the files returned by the globs match the supplied string, or if no files are returned. | +| `size` | **Yes** | `number` | | files sizes larger than this number (bytes) will fail this rule. | + ### `json-schema-passes` Checks if a given file matches a provided [JSON schema](https://json-schema.org/). This check is performed using [AJV](https://ajv.js.org/). diff --git a/rules/file-hashes-not-exist.js b/rules/file-hashes-not-exist.js index 7dd33a39..c22110a1 100644 --- a/rules/file-hashes-not-exist.js +++ b/rules/file-hashes-not-exist.js @@ -4,7 +4,7 @@ const crypto = require('crypto') const FileSystem = require('../lib/file_system') /** - * Check files not include a list of certain cryptographic hashes. + * Check files' hashes not included in a list of certain cryptographic hashes. * * @param {FileSystem} fs A filesystem object configured with filter paths and target directories * @param {object} options The rule configuration diff --git a/rules/file-not-contents-config.json b/rules/file-not-contents-config.json index 24f5fd1c..677412ab 100644 --- a/rules/file-not-contents-config.json +++ b/rules/file-not-contents-config.json @@ -1,6 +1,6 @@ { "$schema": "http://json-schema.org/draft-07/schema", - "$id": "https://raw.githubusercontent.com/todogroup/repolinter/master/rules/file-not-contents-config.json", + "$id": "https://raw.githubusercontent.com/todogroup/repolinter/master/rules/file-hashes-not-exist-config.json", "type": "object", "properties": { "nocase": {