@grafana/plugin-validator 0.7.4 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +169 -153
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,45 +1,102 @@
1
1
  # Grafana Plugin Validator
2
2
 
3
3
  [![License](https://img.shields.io/github/license/grafana/plugin-validator)](LICENSE)
4
+ [![Drone](https://drone.grafana.net/api/badges/grafana/plugin-validator/status.svg)](https://drone.grafana.net/grafana/plugin-validator)
5
+ [![Go Report Card](https://goreportcard.com/badge/github.com/grafana/plugin-validator)](https://goreportcard.com/report/github.com/grafana/plugin-validator)
4
6
 
5
- A tool for validating community plugins for publishing to Grafana.com.
7
+ The tool helps speed up the process of publishing plugins to [Grafana.com](https://grafana.com/grafana/plugins/). It runs a series of [analyzers](#analyzers) to ensure plugins are following best practices; checking for security and structural issues, as well as specific requirements related to publishing. A general overview of these requirements can be found here: <https://grafana.com/docs/grafana/latest/developers/plugins/publishing-and-signing-criteria/>.
6
8
 
7
- The tool expects path to either a remote or a local ZIP archive.
9
+ It requires a path to a remote or local ZIP archive of the plugin to be specified, for example:
8
10
 
9
- ## Install
11
+ - **Remote**: `https://github.com/grafana/clock-panel/releases/download/v2.1.2/grafana-clock-panel-2.1.2.zip`
12
+ - **Local**: `file://Users/me/Downloads/grafana-clock-panel-2.1.2.zip`
13
+
14
+ You can **additionally** provide a link to the source code for the project with `-sourceCodeUri` to enable additional analyzers such as the Vulnerability Scan.
15
+
16
+ ## Installation and usage
17
+
18
+ ### Docker (recommended)
19
+
20
+ It is easiest to run the tool using the Docker image as it contains all the [security scanning tools](#security-tools) needed for the full set of analyzers - so you don't need to have these additional tools installed on your system.
10
21
 
11
22
  ```SHELL
12
- cd pkg/cmd/plugincheck2
13
- go install
23
+ docker run --pull=always grafana/plugin-validator-cli [options] [path/to/plugin_archive.zip]
24
+ ```
25
+
26
+ #### Example 1 (basic)
27
+
28
+ ```SHELL
29
+ docker run --pull=always grafana/plugin-validator-cli https://github.com/grafana/clock-panel/releases/download/v2.1.2/grafana-clock-panel-2.1.2.zip
14
30
  ```
15
31
 
16
- ## Run
32
+ #### Example 2 (specifying source code location)
17
33
 
18
- Typically running the checker with default settings is the easiest method to see if there are issues with a plugin.
34
+ ```SHELL
35
+ docker run --pull=always grafana/plugin-validator-cli -sourceCodeUri https://github.com/grafana/clock-panel/tree/v2.1.2 https://github.com/grafana/clock-panel/releases/download/v2.1.2/grafana-clock-panel-2.1.2.zip
36
+ ```
37
+
38
+ ### NPX
19
39
 
20
40
  ```SHELL
21
- plugincheck2 -config config/default.yaml https://github.com/marcusolsson/grafana-jsonapi-datasource/releases/download/v0.6.0/marcusolsson-json-datasource-0.6.0.zip
41
+ npx -y @grafana/plugin-validator@latest -sourceCodeUri [options] [path/to/plugin_archive.zip]
22
42
  ```
23
43
 
24
- To wrap the output with another tool (like the validator ui), running with the `terse-json.yaml` config can be used.
44
+ ### Locally
45
+
46
+ First you must compile and install it:
25
47
 
26
48
  ```SHELL
27
- plugincheck2 -config config/terse-json.yaml https://github.com/marcusolsson/grafana-jsonapi-datasource/releases/download/v0.6.0/marcusolsson-json-datasource-0.6.0.zip
49
+ git clone git@github.com:grafana/plugin-validator.git
50
+ cd plugin-validator/pkg/cmd/plugincheck2
51
+ go install
28
52
  ```
29
53
 
30
- Verbose json output is available to show all checks made, with status for each.
54
+ Then you can run the utility:
31
55
 
32
56
  ```SHELL
33
- plugincheck2 -config config/verbose-json.yaml https://github.com/marcusolsson/grafana-jsonapi-datasource/releases/download/v0.6.0/marcusolsson-json-datasource-0.6.0.zip
57
+ plugincheck2 -sourceCodeUri [source_code_location/] [plugin_archive.zip]
58
+ ```
59
+
60
+ ### Generating Local Files For Validation
61
+
62
+ You must create a `.zip` archive containing the `dist/` directory but named as your plugin ID.
63
+
64
+ ```SHELL
65
+ PLUGIN_ID=$(grep '"id"' < src/plugin.json | sed -E 's/.*"id" *: *"(.*)".*/\1/')
66
+ cp -r dist "${PLUGIN_ID}"
67
+ zip -qr "${PLUGIN_ID}.zip" "${PLUGIN_ID}"
68
+ npx @grafana/plugin-validator@latest -sourceCodeUri file://. "${PLUGIN_ID}.zip"
69
+ ```
70
+
71
+ You can optionally remove the files that were generated:
72
+
73
+ ```SHELL
74
+ rm -r "${PLUGIN_ID}" "${PLUGIN_ID}.zip"
75
+ ```
76
+
77
+ ## Options
78
+
79
+ Additional options can be passed to the tool:
80
+
34
81
  ```
82
+ ❯ plugincheck2 -help
83
+ Usage plugincheck2:
84
+ -config string (optional)
85
+ Path to configuration file
86
+ -sourceCodeUri string (optional)
87
+ URI to the source code of the plugin. If set, the source code will be downloaded and analyzed. This can be a ZIP file URL, a URL to git repository or a local file (starting with `file://`)
88
+ -strict (optional)
89
+ If set, plugincheck returns non-zero exit code for warnings
35
90
 
36
- ## Configuration
91
+ ```
92
+
93
+ ### Using a configuration file
37
94
 
38
- You must pass a configuration file to the validator with the `-config` option. Several configuraton examples are available to use here <https://github.com/grafana/plugin-validator/tree/main/config>
95
+ You can pass a configuration YAML file to the validator with the `-config` option. Several configuration examples are available to use here <https://github.com/grafana/plugin-validator/tree/main/config>
39
96
 
40
- ### Enabling and disabling analyzers via config
97
+ #### Enabling and disabling analyzers via config
41
98
 
42
- If you wish to disable an specific check (analyzer) you can define this in your configuration file adding an `analyzers` section and specyfing which analyzer or analyzer rules to enable and disable.
99
+ If you wish to disable an specific check (analyzer) you can define this in your [configuration file](#using-a-configuration-file), adding an `analyzers` section and specifying which analyzer or analyzer rules to enable and disable.
43
100
 
44
101
  E.g.: disable the `version` analyzer
45
102
 
@@ -72,148 +129,126 @@ analyzers:
72
129
 
73
130
  Severity levels could be: `error`, `warning`, `ok`
74
131
 
75
- Please notice that Grafanalabs uses its own configuration for plugins submissions and your own config file can't change these rules.
76
-
77
- ## Analyzers
78
-
79
- The plugincheck tool runs a series of analyzers to ensure submitted plugins are following best practices, and speed up the process of approving a plugin for publishing.
80
-
81
- Currently there are 20 different types of checks being performed, and are described below.
82
-
83
- ### Archive Structure
84
-
85
- Ensures the contents of the zip file have the expected layout.
86
-
87
- ### Archive Name
88
-
89
- The name of the archive should be correctly formatted.
90
-
91
- ### Binary Permissions
92
-
93
- For datasources and apps with binaries, this ensures the plugin can run when extracted on a system.
94
-
95
- ### Broken Links
96
-
97
- Detects if any url does not resolve to a valid location.
98
-
99
- ### HTML in Readme
100
-
101
- Detects if there are any html tags used in the README.md, as they will not render in the marketplace.
102
-
103
- ### Developer Jargon
104
-
105
- Generally discourage use of code jargon in the documentation.
106
-
107
- ### Legacy Platform
108
-
109
- ### License Type
110
-
111
- Ensures the license type specified is allowed.
112
-
113
- ### Manifest (Signing)
114
-
115
- When a plugin is signed, the zip file will contain a signed MANIFEST.txt file.
116
-
117
- ### Metadata Paths and Validity
118
-
119
- Ensures all paths are valid and images referenced exist.
120
-
121
- ### module.js (exists)
122
-
123
- All plugins require a module.js to be loaded.
132
+ > Note: Grafana Labs enforces its own configuration for plugins submissions and your own config file can't change these rules.
124
133
 
125
- ### Organization exists
134
+ ### Source code
126
135
 
127
- Verifies the org specified in the plugin id exists.
136
+ You can specify the location of the plugin source code to the validator with the `-sourceCodeUri` option. Doing so allows for additional [analyzers](#analyzers) to be run and for a more complete scan.
128
137
 
129
- ### Plugin Name formatting
138
+ ### Supported remote Git services
130
139
 
131
- Validates the plugin id used conforms to our naming convention.
140
+ The following **public** git services are supported
132
141
 
133
- ### Readme (exists)
142
+ - GitHub
143
+ - GitLab
144
+ - Bitbucket
134
145
 
135
- Ensures a README.md file exists within the zip file.
146
+ Private repositories are not currently supported.
136
147
 
137
- ### Restrictive Dependency
148
+ Make sure to include the ref (branch or tag) of the corresponding source code.
138
149
 
139
- Specifies a valid range of Grafana that works with this version of the plugin.
150
+ e.g.: You are validating version `v2.1.2` and your project is in github. Make sure you create a corresponding tag or branch and use the url `https://github.com/grafana/clock-panel/tree/v2.1.2`
140
151
 
141
- ### Screenshots
152
+ ## Debug mode
142
153
 
143
- Screenshots are specified in plugin.json that will be used in the marketplace.
154
+ You can run the validator in debug mode to get more information about the running checks and possible errors.
144
155
 
145
- ### Signature
156
+ Docker:
146
157
 
147
- Ensures the plugin has a valid signature.
148
-
149
- ### Source Code (NEW!)
150
-
151
- The source code URI matches the released code. A comparison is made between the zip file and the source code to ensure what is released matches the repo associated with it.
152
-
153
- ### Unique README.md
154
-
155
- Ensures the plugin does not re-use the template from the create-plugin tool.
156
-
157
- ### No Tracking Scripts
158
-
159
- Detects if there are any known tracking scripts, which are not allowed.
160
-
161
- ### Type Suffix (panel/app/datasource)
158
+ ```SHELL
159
+ docker run --pull=always -e DEBUG=1 grafana/plugin-validator-cli -sourceCodeUri https://github.com/grafana/clock-panel/tree/v2.1.2 https://github.com/grafana/clock-panel/releases/download/v2.1.2/grafana-clock-panel-2.1.2.zip
160
+ ```
162
161
 
163
- Ensures the plugin has a valid type specified.
162
+ NPX:
164
163
 
165
- ### Version
164
+ ```SHELL
165
+ DEBUG=1 npx -y @grafana/plugin-validator@latest -sourceCodeUri https://github.com/grafana/clock-panel/tree/v2.1.2 https://github.com/grafana/clock-panel/releases/download/v2.1.2/grafana-clock-panel-2.1.2.zip
166
+ ```
166
167
 
167
- Ensures the version submitted is newer than the currently published plugin. If this is a new/unpublished plugin, this is skipped.
168
+ Locally:
168
169
 
169
- ### Vulnerability Scanner
170
+ ```SHELL
171
+ DEBUG=1 plugincheck2 -sourceCodeUri https://github.com/grafana/clock-panel/tree/v2.1.2 https://github.com/grafana/clock-panel/releases/download/v2.1.2/grafana-clock-panel-2.1.2.zip
172
+ ```
170
173
 
171
- This analyzer leverages the OSV Scanner (<https://github.com/google/osv-scanner>) to detect critical vulnerabilities in go modules and yarn lock files.
174
+ ## Security tools
172
175
 
173
- Any critical vulnerability will cause the validation to fail and prevent a plugin from being published.
176
+ This validator makes uses of the following open source security tools:
174
177
 
175
- Source code must be provided for this analyzer to execute, and osv-scanner needs to be in your PATH for it to run.
178
+ - [osv-scanner](https://github.com/google/osv-scanner)
179
+ - [semgrep](https://github.com/returntocorp/semgrep)
180
+ - [gosec](https://github.com/securego/gosec)
176
181
 
177
- #### Running this Analyzer
182
+ If you run the validator locally or via NPX you can benefit from installing these tools in your system to make them part of your validation checks.
178
183
 
179
- Default Usage:
184
+ ---
180
185
 
181
- ```SHELL
182
- plugincheck2 -config config/default.yaml -sourceCodeUri https://github.com/briangann/grafana-gauge-panel/archive/refs/tags/v0.0.9.zip https://github.com/briangann/grafana-gauge-panel/releases/download/v0.0.9/briangann-gauge-panel-0.0.9.zip
183
- ```
186
+ ## Analyzers
184
187
 
185
- Example default output:
188
+ The tool runs a series of analyzers to ensure submitted plugins are following best practices, and speed up the process of approving a plugin for publishing, detailed in the table below. The Analyzer column includes the name required for altering the behavior of a given check in a [configuration file](#using-a-configuration-file). The Dependencies column specifies whether the analyzer requires the source code for the plugin to be provided with `sourceCodeUri` or for any additional [security scanning tools](#security-tools) to be present.
189
+
190
+ | Analyzer | Description | Dependencies |
191
+ | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
192
+ | Archive Structure / `archive` | Ensures the contents of the zip file have the expected layout. | None |
193
+ | Archive Name / `archivename` | The name of the archive should be correctly formatted. | None |
194
+ | Backend Debug / `backenddebug` | Checks that the standalone debug files for backend plugins are not present. | None |
195
+ | Binary Permissions / `binarypermissions` | For datasources and apps with binaries, this ensures the plugin can run when extracted on a system. | None |
196
+ | Broken Links / `brokenlinks` | Detects if any url does not resolve to a valid location. | None |
197
+ | Code Rules / `coderules` | Checks for forbidden access to environment variables, file system or use of `syscall` module. | [semgrep](https://github.com/returntocorp/semgrep), `sourceCodeUri` |
198
+ | Go Manifest / `gomanifest` | Validates the build manifest. | `sourceCodeUri` |
199
+ | Go Security Checker / `gosec` | Inspects source code for security problems by scanning the Go AST. | [gosec](https://github.com/securego/gosec), `sourceCodeUri` |
200
+ | JS Source Map / `jssourcemap` | Checks for required module.js.map file(s) in archive. | `sourceCodeUri` |
201
+ | Logos / `logos` | Detects whether the plugin includes small and large logos to display in the marketplace. | none |
202
+ | HTML in Readme / `htmlreadme` | Detects if there are any html tags used in the README.md, as they will not render in the marketplace. | None |
203
+ | Developer Jargon / `jargon` | Generally discourage use of code jargon in the documentation. | None |
204
+ | Legacy Platform / `legacyplatform` | Detects use of Angular which is deprecated. | None |
205
+ | License Type / `license` | Checks the declared license is one of: BSD, MIT, Apache 2.0, LGPL3, GPL3, AGPL3. | None |
206
+ | Manifest (Signing) / `manifest` | When a plugin is signed, the zip file will contain a signed MANIFEST.txt file. | None |
207
+ | Metadata Paths / `metadapaths` | Ensures all paths are valid and images referenced exist. | None |
208
+ | Metadata Validity / `metadatavalid` | Ensures metadata is valid and matches plugin schema. | None |
209
+ | module.js (exists) / `modulejs` | All plugins require a module.js to be loaded. | None |
210
+ | Organization (exists) / `org` | Verifies the org specified in the plugin id exists. | None |
211
+ | Plugin Name formatting / `pluginname` | Validates the plugin id used conforms to our naming convention. | None |
212
+ | Published / `published` | Detects whether any version of this plugin exists on the marketplace currently | None |
213
+ | Readme (exists) / `readme` | Ensures a README.md file exists within the zip file. | None |
214
+ | Restrictive Dependency / `restrictivedep` | Specifies a valid range of Grafana versions that work with this version of the plugin. | None |
215
+ | Screenshots / `screenshots` | Screenshots are specified in plugin.json that will be used in the marketplace. | None |
216
+ | Signature / `signature` | Ensures the plugin has a valid signature. | None |
217
+ | !Source Code / `sourcecode` | A comparison is made between the zip file and the source code to ensure what is released matches the repo associated with it. | `sourceCodeUri` |
218
+ | Unique README.md / `templatereadme` | Ensures the plugin does not re-use the template from the create-plugin tool. | None |
219
+ | No Tracking Scripts / `trackingscripts` | Detects if there are any known tracking scripts, which are not allowed. | None |
220
+ | Type Suffix (panel/app/datasource) / `typesuffix` | Ensures the plugin has a valid type specified. | None |
221
+ | Version / `version` | Ensures the version submitted is newer than the currently published plugin. If this is a new/unpublished plugin, this is skipped. | None |
222
+ | Vulnerability Scanner / `osv-scanner` | Detects critical vulnerabilities in go modules and yarn lock files. | [osv-scanner](https://github.com/google/osv-scanner), `sourceCodeUri` |
223
+ | Unsafe SVG / `unsafesvg` | Checks if any svg files are safe based on a whitelist of elements and attributes | none |
224
+
225
+ ## Output
226
+
227
+ By default, the tool will output results in plain text as shown below.
228
+
229
+ Default:
186
230
 
187
231
  ```TEXT
188
232
  warning: README.md: possible broken link: https://www.d3js.org (404 Not Found)
189
- detail: README.md might contain broken links. Check that all links are valid and publicly accesible.
233
+ detail: README.md might contain broken links. Check that all links are valid and publicly accessible.
190
234
  warning: README.md contains developer jargon: (yarn)
191
235
  detail: Move any developer and contributor documentation to a separate file and link to it from the README.md. For example, CONTRIBUTING.md, DEVELOPMENT.md, etc.
192
236
  error: osv-scanner detected a critical severity issue
193
237
  detail: SEVERITY: CRITICAL in package immer, vulnerable to CVE-2021-23436
194
238
  error: osv-scanner detected a critical severity issue
195
239
  detail: SEVERITY: CRITICAL in package json-schema, vulnerable to CVE-2021-3918
196
- error: osv-scanner detected a critical severity issue
197
- detail: SEVERITY: CRITICAL in package loader-utils, vulnerable to CVE-2022-37601
198
- error: osv-scanner detected a critical severity issue
199
- detail: SEVERITY: CRITICAL in package minimist, vulnerable to CVE-2021-44906
200
- error: osv-scanner detected a critical severity issue
201
- detail: SEVERITY: CRITICAL in package shell-quote, vulnerable to CVE-2021-42740
202
- error: osv-scanner detected a critical severity issue
203
- detail: SEVERITY: CRITICAL in package simple-git, vulnerable to CVE-2022-25860
204
- error: osv-scanner detected critical severity issues
205
- detail: osv-scanner detected 6 unique critical severity issues for lockfile: /var/folders/84/yw3k27_j0d79r_myzgjgx1980000gn/T/validator1049475772/yarn.lock
206
240
  error: Plugin version 0.0.9 is invalid.
207
241
  detail: The submitted plugin version 0.0.9 is not greater than the latest published version 0.0.9 on grafana.com.
208
242
  ```
209
243
 
210
- Terse JSON Output:
244
+ This can be changed to JSON by passing a configuration file which includes:
211
245
 
212
- ```SHELL
213
- plugincheck2 -config config/terse-json.yaml -sourceCodeUri https://github.com/briangann/grafana-gauge-panel/archive/refs/tags/v0.0.9.zip https://github.com/briangann/grafana-gauge-panel/releases/download/v0.0.9/briangann-gauge-panel-0.0.9.zip
246
+ ```yaml
247
+ global:
248
+ jsonOutput: true
214
249
  ```
215
250
 
216
- JSON:
251
+ Resulting in output similar to:
217
252
 
218
253
  ```JSON
219
254
  {
@@ -224,7 +259,7 @@ JSON:
224
259
  {
225
260
  "Severity": "warning",
226
261
  "Title": "README.md: possible broken link: https://www.d3js.org (404 Not Found)",
227
- "Detail": "README.md might contain broken links. Check that all links are valid and publicly accesible.",
262
+ "Detail": "README.md might contain broken links. Check that all links are valid and publicly accessible.",
228
263
  "Name": "broken-link"
229
264
  }
230
265
  ],
@@ -249,36 +284,6 @@ JSON:
249
284
  "Detail": "SEVERITY: CRITICAL in package json-schema, vulnerable to CVE-2021-3918",
250
285
  "Name": "osvscanner-critical-severity-vulnerabilities-detected"
251
286
  },
252
- {
253
- "Severity": "error",
254
- "Title": "osv-scanner detected a critical severity issue",
255
- "Detail": "SEVERITY: CRITICAL in package loader-utils, vulnerable to CVE-2022-37601",
256
- "Name": "osvscanner-critical-severity-vulnerabilities-detected"
257
- },
258
- {
259
- "Severity": "error",
260
- "Title": "osv-scanner detected a critical severity issue",
261
- "Detail": "SEVERITY: CRITICAL in package minimist, vulnerable to CVE-2021-44906",
262
- "Name": "osvscanner-critical-severity-vulnerabilities-detected"
263
- },
264
- {
265
- "Severity": "error",
266
- "Title": "osv-scanner detected a critical severity issue",
267
- "Detail": "SEVERITY: CRITICAL in package shell-quote, vulnerable to CVE-2021-42740",
268
- "Name": "osvscanner-critical-severity-vulnerabilities-detected"
269
- },
270
- {
271
- "Severity": "error",
272
- "Title": "osv-scanner detected a critical severity issue",
273
- "Detail": "SEVERITY: CRITICAL in package simple-git, vulnerable to CVE-2022-25860",
274
- "Name": "osvscanner-critical-severity-vulnerabilities-detected"
275
- },
276
- {
277
- "Severity": "error",
278
- "Title": "osv-scanner detected critical severity issues",
279
- "Detail": "osv-scanner detected 6 unique critical severity issues for lockfile: /var/folders/84/yw3k27_j0d79r_myzgjgx1980000gn/T/validator1150112313/yarn.lock",
280
- "Name": "osvscanner-critical-severity-vulnerabilities-detected"
281
- }
282
287
  ],
283
288
  "version": [
284
289
  {
@@ -292,12 +297,23 @@ JSON:
292
297
  }
293
298
  ```
294
299
 
295
- Verbose
300
+ ### Severity
296
301
 
297
- ```SHELL
298
- plugincheck2 -config config/verbose-json.yaml -sourceCodeUri https://github.com/briangann/grafana-gauge-panel/archive/refs/tags/v0.0.9.zip https://github.com/briangann/grafana-gauge-panel/releases/download/v0.0.9/briangann-gauge-panel-0.0.9.zip
302
+ By default the tool will show any warning or error level results from the analyzers. To see all results including successes, you can pass a configuration file which includes:
303
+
304
+ ```yaml
305
+ global:
306
+ reportAll: true
299
307
  ```
300
308
 
309
+ ## Getting Help
310
+
311
+ - :open_book: Check out our plugin [documentation](https://grafana.com/docs/grafana/latest/developers/plugins/).
312
+ - :rocket: See our other [Plugin Tools](https://grafana.github.io/plugin-tools/) to create and update plugins.
313
+ - :handshake: Join the [community forum](https://community.grafana.com/tag/plugins).
314
+ - :speech_balloon: Chat to us in the Grafana Slack [#plugins channel](https://grafana.slack.com/archives/C3HJV5PNE).
315
+ - :memo: [File an issue](https://github.com/grafana/plugin-validator/issues) for any bugs or feature requests.
316
+
301
317
  ## License
302
318
 
303
319
  Grafana Plugin Validator is distributed under the [Apache 2.0 License](https://github.com/grafana/plugin-validator/blob/master/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-validator",
3
- "version": "0.7.4",
3
+ "version": "0.7.9",
4
4
  "description": "Grafana Plugin Validator",
5
5
  "main": "index.js",
6
6
  "scripts": {