SonarSource / SonarJS

SonarSource Static Analyzer for JavaScript and TypeScript
https://community.sonarsource.com/
GNU Lesser General Public License v3.0
1.03k stars 181 forks source link

Analyze JS inside YAML for AWS Lambdas #3191

Closed ilia-kebets-sonarsource closed 2 years ago

ilia-kebets-sonarsource commented 2 years ago

Decisions

We have decided to drop metrics and highlighting from this sprint as it is not necessary and requires coordination with SQ and other bubbles. Quickfixes are dropped from the scope as they will not be used as long as sonar-iac is not supported by SonarLint.

In case of multiple JS snippets in a single YAML file, the API endpoint /analyze-yaml returns a parsingError property if at least one of them has an error, we have chosen this "fail fast" approach for ease of implementation and so that the user can easily fix this issue and proceed with a well working analysis.

ilia-kebets-sonarsource commented 2 years ago

The API of yaml v1.x is different from the v2.x, so it would require some refactor or impossible to make it work with Node 12.

ilia-kebets-sonarsource commented 2 years ago

Candidates for peach and ruling:

Lambda

Serverless

ilia-kebets-sonarsource commented 2 years ago

As the repositories where we found JS in YAML code are:

We will simply take the YAML file for the ruling. I propose to add them in its/sources/yaml/, adding the source URL as a comment on the top of the file.

ilia-kebets-sonarsource commented 2 years ago

We will ignore the following formats because the parser handles spaces at the beginning of lines in a weird way:

Example:

single-quote: '
  Several lines of text,
  containing ''single quotes''. Escapes (like \n) don''t do anything.
  '
ilia-kebets-sonarsource commented 2 years ago

Since the lib yaml v1.x does not have the following features:

we estimate that refactoring this would be too much work, and we go towards the fork the lib and transpile it into Node12 path.

ilia-kebets-sonarsource commented 2 years ago

Elected for Peachees because from aws-samples org which should be stable:

Lambda (block-literal formats and unsupported ones):

Serverless (plain double-quote format):