@mocoto/mahoraga 0.14.4 → 0.14.6
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.
- package/README.md +9 -39
- package/dist/analysts/architects/archetypes-custom.js +1 -1
- package/dist/analysts/architects/detector-archetypes.js +1 -0
- package/dist/analysts/architects/strategist-structure.js +1 -1
- package/dist/analysts/azure-pipelines/corrections/correction-azure.js +1 -0
- package/dist/analysts/azure-pipelines/detectors/detector-azure-performance.js +1 -0
- package/dist/analysts/azure-pipelines/detectors/detector-azure-security.js +1 -0
- package/dist/analysts/azure-pipelines/detectors/detector-azure-structure.js +1 -0
- package/dist/analysts/azure-pipelines/scorers/scorer-azure.js +1 -0
- package/dist/analysts/circleci/detectors/detector-circleci-performance.js +1 -0
- package/dist/analysts/circleci/detectors/detector-circleci-security.js +1 -0
- package/dist/analysts/circleci/detectors/detector-circleci-structure.js +9 -10
- package/dist/analysts/converters/engines/converter-gha-to-gitlab.js +1 -0
- package/dist/analysts/corrections/corrector-structure.js +2 -2
- package/dist/analysts/corrections/fix-md-fences.js +1 -0
- package/dist/analysts/corrections/map-reversion.js +1 -0
- package/dist/analysts/corrections/quick-fixes/fix-any-to-proper-type.js +1 -0
- package/dist/analysts/corrections/reorganize-barrels.js +1 -0
- package/dist/analysts/corrections/scoring-shared.js +1 -0
- package/dist/analysts/corrections/type-safety/context-analyzer.js +1 -1
- package/dist/analysts/corrections/type-safety/usage-analyzer.js +1 -0
- package/dist/analysts/css/analysts/analyst-css.js +3 -2
- package/dist/analysts/css/corrections/correction-css.js +1 -0
- package/dist/analysts/css/detectors/detector-css-best-practices.js +1 -0
- package/dist/analysts/css/scorers/scorer-css.js +1 -0
- package/dist/analysts/css-in-js/analysts/analyst-css-in-js.js +1 -0
- package/dist/analysts/css-in-js/corrections/correction-css-in-js.js +1 -1
- package/dist/analysts/css-in-js/detectors/detector-css-in-js-best-practices.js +2 -2
- package/dist/analysts/css-in-js/scorers/scorer-css-in-js.js +2 -2
- package/dist/analysts/detectors/detector-bugs-ml.js +4 -2
- package/dist/analysts/detectors/detector-dependencies.js +1 -0
- package/dist/analysts/detectors/detector-monorepo.js +1 -0
- package/dist/analysts/detectors/detector-security.js +1 -1
- package/dist/analysts/github-actions/corrections/correction-workflow.js +1 -0
- package/dist/analysts/github-actions/detectors/detector-dependencies-vulnerable.js +1 -0
- package/dist/analysts/github-actions/detectors/detector-workflow-compliance.js +1 -0
- package/dist/analysts/github-actions/detectors/detector-workflow-performance.js +1 -0
- package/dist/analysts/github-actions/detectors/detector-workflow-security.js +1 -0
- package/dist/analysts/github-actions/detectors/detector-workflow-structure.js +1 -0
- package/dist/analysts/github-actions/detectors/detector-workflow-trigger-unsafe.js +1 -0
- package/dist/analysts/github-actions/scorers/scorer-workflow.js +1 -0
- package/dist/analysts/gitlab-ci/analysts/analyst-gitlab-ci.js +1 -0
- package/dist/analysts/gitlab-ci/corrections/correction-gitlab-ci.js +1 -0
- package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-performance.js +1 -0
- package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-security.js +1 -0
- package/dist/analysts/gitlab-ci/detectors/detector-gitlab-ci-structure.js +1 -0
- package/dist/analysts/go/analysts/analyst-best-practices.js +1 -0
- package/dist/analysts/go/analysts/analyst-concurrency.js +1 -0
- package/dist/analysts/go/analysts/analyst-go.js +1 -0
- package/dist/analysts/go/analysts/analyst-resources.js +1 -0
- package/dist/analysts/go/detectors/detector-conventions.js +1 -0
- package/dist/analysts/go/detectors/detector-errors-un-handled.js +1 -0
- package/dist/analysts/go/detectors/detector-vulnerabilities.js +1 -0
- package/dist/analysts/html/analysts/analyst-html.js +1 -0
- package/dist/analysts/html/corrections/correction-html.js +1 -0
- package/dist/analysts/html/detectors/detector-html-accessibility.js +1 -0
- package/dist/analysts/html/detectors/detector-html.js +1 -0
- package/dist/analysts/jenkins/analysts/analyst-jenkins.js +1 -0
- package/dist/analysts/jenkins/corrections/correction-jenkins.js +1 -0
- package/dist/analysts/jenkins/detectors/detector-jenkins-best-practices.js +1 -0
- package/dist/analysts/jenkins/detectors/detector-jenkins-security.js +1 -0
- package/dist/analysts/jenkins/scorers/scorer-jenkins.js +1 -0
- package/dist/analysts/js-ts/analysts/analyst-todo-comments.js +1 -6
- package/dist/analysts/js-ts/detectors/detector-context-smart.js +1 -0
- package/dist/analysts/js-ts/detectors/detector-interfaces-inline.js +1 -0
- package/dist/analysts/js-ts/detectors/detector-leaks-memory.js +1 -0
- package/dist/analysts/js-ts/detectors/detector-types-unsafe.js +88 -5
- package/dist/analysts/php/analysts/analyst-php.js +1 -0
- package/dist/analysts/php/detectors/detector-php-best-practices.js +1 -0
- package/dist/analysts/php/detectors/detector-php-security.js +1 -0
- package/dist/analysts/plugins/analyst-formatter.js +1 -0
- package/dist/analysts/plugins/detector-markdown.js +1 -0
- package/dist/analysts/python/analysts/analyst-python.js +2 -1
- package/dist/analysts/python/corrections/correction-python.js +1 -0
- package/dist/analysts/python/scorers/scorer-python.js +1 -0
- package/dist/analysts/react/analysts/analyst-react-hooks.js +109 -12
- package/dist/analysts/react/analysts/analyst-react.js +12 -0
- package/dist/analysts/react/detectors/detector-react-best-practices.js +24 -1
- package/dist/analysts/react/scorers/scorer-react.js +4 -1
- package/dist/analysts/registry/autodiscovery.js +1 -0
- package/dist/analysts/rust/analysts/analyst-best-practices.js +1 -0
- package/dist/analysts/rust/analysts/analyst-concurrency.js +1 -0
- package/dist/analysts/rust/analysts/analyst-memory.js +1 -0
- package/dist/analysts/rust/analysts/analyst-rust.js +1 -0
- package/dist/analysts/rust/analysts/analyst-security.js +1 -0
- package/dist/analysts/rust/detectors/detector-conventions.js +1 -0
- package/dist/analysts/rust/detectors/detector-errors-potential.js +1 -0
- package/dist/analysts/shell/analysts/analyst-shell.js +1 -0
- package/dist/analysts/shell/corrections/correction-shell.js +1 -0
- package/dist/analysts/shell/detectors/detector-shell-security.js +1 -0
- package/dist/analysts/shell/scorers/scorer-shell.js +1 -0
- package/dist/analysts/sql/corrections/correction-sql.js +1 -0
- package/dist/analysts/sql/detectors/detector-sql.js +1 -0
- package/dist/analysts/sql/scorers/scorer-sql.js +1 -0
- package/dist/analysts/strategists/operator-structure.js +1 -1
- package/dist/analysts/strategists/suggestions-contextuais.js +1 -0
- package/dist/analysts/svg/analysts/analyst-svg.js +1 -0
- package/dist/analysts/svg/corrections/correction-svg.js +1 -0
- package/dist/analysts/svg/detectors/detector-svg-security.js +1 -0
- package/dist/analysts/tailwind/analysts/analyst-tailwind.js +6 -2
- package/dist/analysts/tailwind/corrections/correction-tailwind.js +1 -0
- package/dist/analysts/tailwind/detectors/detector-tailwind-best-practices.js +1 -0
- package/dist/analysts/xml/analysts/analyst-xml.js +1 -0
- package/dist/analysts/xml/corrections/correction-xml.js +1 -0
- package/dist/analysts/xml/detectors/detector-xml-security.js +1 -0
- package/dist/analysts/xml/scorers/scorer-xml.js +1 -0
- package/dist/app/github.js +1 -0
- package/dist/bin/cli-bootstrap.js +1 -1
- package/dist/bin/index.js +1 -1
- package/dist/caretakers/caretaker-imports.js +1 -0
- package/dist/cli/commands/command-analysts.js +1 -0
- package/dist/cli/commands/command-azure.js +1 -0
- package/dist/cli/commands/command-barrels.js +1 -0
- package/dist/cli/commands/command-circleci.js +1 -0
- package/dist/cli/commands/command-compliance.js +1 -0
- package/dist/cli/commands/command-convert.js +1 -0
- package/dist/cli/commands/command-diagnose.js +1 -1
- package/dist/cli/commands/command-fix-types.js +1 -1
- package/dist/cli/commands/command-format.js +1 -0
- package/dist/cli/commands/command-formatters.js +1 -0
- package/dist/cli/commands/command-github-actions.js +1 -0
- package/dist/cli/commands/command-gitlab-ci.js +1 -0
- package/dist/cli/commands/command-guardian.js +1 -1
- package/dist/cli/commands/command-imports.js +1 -0
- package/dist/cli/commands/command-jenkins.js +1 -0
- package/dist/cli/commands/command-licenses.js +1 -0
- package/dist/cli/commands/command-marketplace.js +1 -0
- package/dist/cli/commands/command-metrics.js +1 -1
- package/dist/cli/commands/command-names.js +1 -0
- package/dist/cli/commands/command-optimize-svg.js +1 -0
- package/dist/cli/commands/command-perf.js +1 -0
- package/dist/cli/commands/command-plugins.js +1 -0
- package/dist/cli/commands/command-prune.js +1 -0
- package/dist/cli/commands/command-reverter.js +1 -0
- package/dist/cli/commands/command-update.js +1 -0
- package/dist/cli/diagnostic/auto-fix.js +1 -0
- package/dist/cli/diagnostic/exporters/json-exporter.js +1 -0
- package/dist/cli/diagnostic/exporters/sharded-exporter.js +1 -1
- package/dist/cli/diagnostic/handlers/auto-fix-handler.js +1 -0
- package/dist/cli/diagnostic/handlers/guardian-handler.js +1 -0
- package/dist/cli/diagnostic/processing-diagnostic.js +1 -0
- package/dist/cli/diagnostic/processing-helpers.js +1 -0
- package/dist/cli/handlers/command-vulnerabilities.js +1 -0
- package/dist/cli/handlers/fix-types-exporter.js +1 -0
- package/dist/cli/handlers/guardian-exporter.js +1 -0
- package/dist/cli/helpers/display-frame.js +1 -0
- package/dist/core/config/auto/validation.js +1 -0
- package/dist/core/config/config.js +1 -0
- package/dist/core/config/excludes-padrao.js +1 -0
- package/dist/core/execution/executor.js +1 -0
- package/dist/core/execution/inquisitor.js +1 -0
- package/dist/core/formatters/registro-builtin.js +1 -0
- package/dist/core/messages/en/analysts/detector-react-messages.js +3 -0
- package/dist/core/messages/en/analysts/report-circleci-messages.js +5 -5
- package/dist/core/messages/en/cli/cli-command-marketplace-messages.js +1 -0
- package/dist/core/messages/en/core/plugin-messages.js +1 -1
- package/dist/core/messages/en/log/log-helper.js +1 -1
- package/dist/core/messages/en/ui/suggestions.js +1 -1
- package/dist/core/messages/ja/analysts/report-circleci-messages.js +5 -5
- package/dist/core/messages/ja/core/plugin-messages.js +1 -1
- package/dist/core/messages/ja/log/log-helper.js +1 -1
- package/dist/core/messages/ja/ui/suggestions.js +1 -1
- package/dist/core/messages/pt/analysts/detector-react-messages.js +3 -0
- package/dist/core/messages/pt/analysts/report-circleci-messages.js +5 -5
- package/dist/core/messages/pt/core/plugin-messages.js +1 -1
- package/dist/core/messages/pt/log/log-helper.js +1 -1
- package/dist/core/messages/pt/ui/suggestions.js +1 -1
- package/dist/core/messages/shared/icons.js +1 -0
- package/dist/core/messages/zh/analysts/report-circleci-messages.js +5 -5
- package/dist/core/messages/zh/core/plugin-messages.js +1 -1
- package/dist/core/messages/zh/log/log-helper.js +1 -1
- package/dist/core/messages/zh/ui/suggestions.js +1 -1
- package/dist/core/parsing/langs/css.js +1 -0
- package/dist/core/parsing/langs/html.js +1 -0
- package/dist/core/parsing/langs/json.js +1 -0
- package/dist/core/parsing/langs/php.js +1 -0
- package/dist/core/parsing/langs/python.js +1 -0
- package/dist/core/parsing/langs/rust.js +1 -0
- package/dist/core/parsing/langs/scss.js +1 -0
- package/dist/core/parsing/langs/shell.js +1 -0
- package/dist/core/parsing/langs/vue.js +1 -0
- package/dist/core/parsing/parser.js +1 -0
- package/dist/core/utils/exec-safe.js +23 -5
- package/dist/core/workers/worker-executor.js +1 -0
- package/dist/core/workers/worker-pool.js +0 -0
- package/dist/licenses/disclaimer.js +1 -0
- package/dist/licenses/generate-notices.js +1 -0
- package/dist/licenses/normalizer.js +1 -0
- package/dist/licenses/scanner.js +1 -0
- package/dist/node.loader.js +1 -1
- package/dist/reports/filter-smart.js +1 -1
- package/dist/reports/report-archetypes.js +1 -0
- package/dist/shared/data-processing/fragment-report.js +1 -0
- package/dist/shared/data-processing/json.js +1 -0
- package/dist/shared/formatters/engines/prettier.js +1 -0
- package/dist/shared/formatters/engines/stylelint.js +1 -0
- package/dist/shared/formatters/formatters/code.js +1 -0
- package/dist/shared/formatters/formatters/css.js +1 -0
- package/dist/shared/formatters/formatters/dockerfile.js +1 -0
- package/dist/shared/formatters/formatters/dotfiles.js +1 -0
- package/dist/shared/formatters/formatters/go.js +1 -0
- package/dist/shared/formatters/formatters/html.js +1 -0
- package/dist/shared/formatters/formatters/json.js +1 -0
- package/dist/shared/formatters/formatters/markdown.js +1 -0
- package/dist/shared/formatters/formatters/shell.js +1 -0
- package/dist/shared/formatters/formatters/sql.js +1 -0
- package/dist/shared/formatters/formatters/toml.js +1 -0
- package/dist/shared/formatters/formatters/xml.js +1 -0
- package/dist/shared/formatters/formatters/yaml.js +1 -0
- package/dist/shared/helpers/analyst-wrapper.js +1 -0
- package/dist/shared/helpers/detectors-common.js +1 -0
- package/dist/shared/helpers/framework-detector.js +1 -0
- package/dist/shared/helpers/imports.js +1 -1
- package/dist/shared/helpers/reader-report.js +1 -0
- package/dist/shared/helpers/rule-config.js +1 -0
- package/dist/shared/helpers/suppressao.js +1 -0
- package/dist/shared/marketplace/remote.js +1 -0
- package/dist/shared/persistence/persistence.js +3 -3
- package/dist/shared/plugins/registry.js +1 -0
- package/dist/types/analysts/css-in-js.js +2 -0
- package/dist/types/analysts/index.js +1 -0
- package/dist/types/processing/display.js +1 -1
- package/dist/types/processing/filters.js +1 -0
- package/dist/vulnerabilities/scanner.js +1 -0
- package/package.json +1 -1
- package/dist/index.js +0 -2
- package/dist/sdk/analyzer.js +0 -88
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/sdk-legacy.js +0 -36
- package/dist/types/sdk/analyzer.js +0 -1
- package/dist/types/sdk/index.js +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { getMessages } from '../messages/index.js';
|
|
3
4
|
import { getGlobalRegistry, initializeDefaultPlugins } from '../../shared/plugins/index.js';
|
|
4
5
|
import { parseComBabel, parseComCss, parseComGo, parseComHtmlFunc, parseComJson, parseComMarkdown, parseComPhp, parseComPython, parseComRust, parseComScss, parseComShell, parseComText, parseComTypeScript, parseComVue, parseComXml, parseComYaml, } from './langs/index.js';
|
|
@@ -2,19 +2,37 @@
|
|
|
2
2
|
import { execSync } from 'node:child_process';
|
|
3
3
|
import { config } from '../config/index.js';
|
|
4
4
|
import { getMessages } from '../messages/index.js';
|
|
5
|
+
// Expressão regular para detectar shell metacharacters perigosos
|
|
6
|
+
// que permitiriam injeção de comandos adicionais.
|
|
7
|
+
// Bloqueia: ; | & ` $() ${} <> \n
|
|
8
|
+
const SHELL_INJECTION_RE = /[;|&`]|\$[({]|\${|>|<|\\n/;
|
|
9
|
+
/**
|
|
10
|
+
* Valida que o comando não contém caracteres de injeção shell.
|
|
11
|
+
* @param cmd - Comando a validar
|
|
12
|
+
* @throws Error se o comando contiver padrões perigosos
|
|
13
|
+
*/
|
|
14
|
+
function validarComando(cmd) {
|
|
15
|
+
if (SHELL_INJECTION_RE.test(cmd)) {
|
|
16
|
+
throw new Error(`Comando rejeitado por segurança: contém caracteres de injeção shell.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function verificarSafeMode() {
|
|
20
|
+
if (config.SAFE_MODE && !config.ALLOW_EXEC) {
|
|
21
|
+
throw new Error(getMessages().ExecSafeMensagens.safeModeBloqueado);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
5
24
|
/**
|
|
6
25
|
* Executa um comando shell de forma segura.
|
|
7
26
|
* Bloqueia a execução quando SAFE_MODE está ativo e ALLOW_EXEC não está habilitado.
|
|
27
|
+
* Também valida o comando contra injeção shell mesmo quando a execução é permitida.
|
|
8
28
|
* @param cmd - Comando shell a executar
|
|
9
29
|
* @param opts - Opções do execSync do Node.js
|
|
10
30
|
* @returns Buffer ou string com a saída do comando
|
|
11
|
-
* @throws Error se SAFE_MODE estiver ativo sem ALLOW_EXEC
|
|
31
|
+
* @throws Error se SAFE_MODE estiver ativo sem ALLOW_EXEC ou se o comando for inválido
|
|
12
32
|
*/
|
|
13
33
|
export function executarShellSeguro(cmd, opts = {}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
throw new Error(getMessages().ExecSafeMensagens.safeModeBloqueado);
|
|
17
|
-
}
|
|
34
|
+
validarComando(cmd);
|
|
35
|
+
verificarSafeMode();
|
|
18
36
|
return execSync(cmd, opts);
|
|
19
37
|
}
|
|
20
38
|
/**
|
|
Binary file
|
package/dist/licenses/scanner.js
CHANGED
package/dist/node.loader.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
// Use "npm run sync-aliases" para atualizar os aliases
|
|
3
|
+
// @mahoraga-disable ml-deep-nesting
|
|
3
4
|
/**
|
|
4
5
|
* Loader ESM Universal - src/
|
|
5
6
|
* Resolver autossuficiente com todas as funcionalidades integradas
|
|
@@ -196,7 +197,6 @@ const aliases = {
|
|
|
196
197
|
"@reports": "./src/reports/index",
|
|
197
198
|
"@reports/compliance": "./src/reports/compliance/index",
|
|
198
199
|
"@scripts": "./src/scripts/index",
|
|
199
|
-
"@sdk": "./src/sdk/index",
|
|
200
200
|
"@shared": "./src/shared/index",
|
|
201
201
|
"@shared/data-processing": "./src/shared/data-processing/index",
|
|
202
202
|
"@shared/formatters": "./src/shared/formatters/index",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
// @mahoraga-disable tipo-literal-inline-complexo ml-deep-nesting
|
|
1
2
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// @mahoraga-disable tipo-literal-inline-complexo
|
|
3
3
|
// Justificativa: tipos locais para filtragem de relatórios
|
|
4
4
|
// Sistema inteligente de filtragem e priorização de relatórios
|
|
5
5
|
// Agrupa problemas similares e prioriza por impacto para evitar sobrecarga de informação
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { createRequire } from 'node:module';
|
|
3
4
|
import { corrigirPontuacaoECodigoConservador, limitarLinhasEmBranco, normalizarFimDeLinha, normalizarNewlinesFinais, normalizarUnicode, removerBom, removerEspacosFinaisPorLinhaComProtecao } from './commons.js';
|
|
4
5
|
const SPECIAL_TITLES_BY_SYMBOL = {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { limitarLinhasEmBranco, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom } from './commons.js';
|
|
3
4
|
/* ────────────────────────── Dockerfile Context-Aware Parser ────────────────────────── */
|
|
4
5
|
const DOCKER_KEYWORDS = new Set([
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { formatarJavaScriptMinimo } from './code.js';
|
|
3
4
|
import { corrigirPontuacaoECodigo, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom } from './commons.js';
|
|
4
5
|
import { formatarCssMinimo } from './css.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { normalizarFimDeLinha, normalizarNewlinesFinais, removerBom, removerEspacosFinaisPorLinha } from './commons.js';
|
|
3
4
|
/* ────────────────────────── JSON Recovery Helpers ────────────────────────── */
|
|
4
5
|
function tentarRecuperarJson(input) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { corrigirPontuacaoECodigo, normalizarFimDeLinha, normalizarNewlinesFinais, removerEspacosFinaisPorLinha } from './commons.js';
|
|
3
4
|
export function matchMarkdownFence(line) {
|
|
4
5
|
const trimmedLeft = line.replace(/^\s+/, '');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { corrigirPontuacaoECodigo, limitarLinhasEmBranco, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom } from './commons.js';
|
|
3
4
|
function parseShellLine(raw, ctx) {
|
|
4
5
|
const trimmed = raw.trimEnd();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { corrigirPontuacaoECodigo, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom } from './commons.js';
|
|
3
4
|
/* ────────────────────────── Keywords ────────────────────────── */
|
|
4
5
|
const SQL_KEYWORDS = new Set(['select', 'from', 'where', 'insert', 'into', 'values', 'update', 'set', 'delete', 'create', 'table', 'drop', 'alter', 'add', 'column', 'index', 'join', 'left', 'right', 'inner', 'outer', 'on', 'and', 'or', 'not', 'in', 'is', 'null', 'as', 'order', 'by', 'group', 'having', 'limit', 'offset', 'union', 'all', 'distinct', 'case', 'when', 'then', 'else', 'end', 'exists', 'between', 'like', 'asc', 'desc', 'primary', 'key', 'foreign', 'references', 'constraint', 'default', 'check', 'unique', 'if', 'begin', 'commit', 'rollback', 'transaction', 'grant', 'revoke', 'with', 'recursive', 'over', 'partition', 'window', 'returning', 'cascade', 'restrict', 'no', 'action', 'using', 'cross', 'natural', 'full', 'replace', 'view', 'trigger', 'function', 'procedure', 'declare', 'fetch', 'cursor', 'open', 'close', 'deallocate']);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { corrigirPontuacaoECodigo, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom } from './commons.js';
|
|
3
4
|
function parseTomlLines(code) {
|
|
4
5
|
const lines = normalizarFimDeLinha(code).split('\n');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { corrigirPontuacaoECodigo, normalizarFimDeLinha, normalizarNewlinesFinais, removerBom, removerEspacosFinaisPorLinha } from './commons.js';
|
|
3
4
|
function tokenizeXml(src) {
|
|
4
5
|
const re = /(<\?[\s\S]*?\?>|<!--[\s\S]*?-->|<!\[CDATA\[[\s\S]*?\]\]>|<!DOCTYPE[\s\S]*?>|<\/?[^>\n]+?>)/gi;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
+
// @mahoraga-disable ml-deep-nesting
|
|
2
3
|
import { limitarLinhasEmBranco, normalizarFimDeLinha, normalizarNewlinesFinais, removerEspacosFinaisPorLinha } from './commons.js';
|
|
3
4
|
function parseYamlLines(code) {
|
|
4
5
|
const lines = normalizarFimDeLinha(code).split('\n');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
// @mahoraga-disable tipo-literal-inline-complexo ml-deep-nesting
|
|
1
2
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// @mahoraga-disable tipo-literal-inline-complexo
|
|
3
3
|
// Justificativa: tipos locais para reescrita de imports
|
|
4
4
|
/**
|
|
5
5
|
* Helper puro para reescrever imports relativos quando um arquivo é movido.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument -- withFsFallback faz dispatch dinâmico de operações fs, impossível de tipar com strict function types */
|
|
2
|
+
// @mahoraga-disable tipo-inseguro-unknown problema-documentacao ml-deep-nesting
|
|
1
3
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// @mahoraga-disable tipo-inseguro-unknown
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-argument -- Wrapper genérico de fs com fallback */
|
|
4
4
|
// Justificativa: unknown é usado para serialização genérica que aceita qualquer entrada
|
|
5
5
|
import * as fsCb from 'node:fs';
|
|
6
6
|
import { promises as fs } from 'node:fs';
|
|
@@ -210,7 +210,7 @@ export async function salvarBinarioAtomico(caminho, dados) {
|
|
|
210
210
|
callbackKey: 'writeFile',
|
|
211
211
|
promisifiedFn: (p, data, opts) => fs.writeFile(p, data, opts),
|
|
212
212
|
callbackFn: (p, data, opts, cb) => { (fsCb.writeFile)(p, data, opts, cb); },
|
|
213
|
-
args: [temporaryValor, dados]
|
|
213
|
+
args: [temporaryValor, dados, {}]
|
|
214
214
|
});
|
|
215
215
|
await withFsFallback({
|
|
216
216
|
promisifiedKey: 'rename',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
// @mahoraga-disable tipo-literal-inline-complexo ml-deep-nesting
|
|
1
2
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// @mahoraga-disable tipo-literal-inline-complexo
|
|
3
3
|
// Justificativa: tipos locais para formatação de display
|
|
4
4
|
import { chalk, config } from '../../core/config/index.js';
|
|
5
5
|
import { getMessages } from '../../core/messages/index.js';
|
package/package.json
CHANGED
package/dist/index.js
DELETED
package/dist/sdk/analyzer.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { executarInquisicao, scanRepository } from '../core/execution/index.js';
|
|
4
|
-
import { decifrarSintaxe } from '../core/parsing/index.js';
|
|
5
|
-
import { asTecnicas } from '../types/index.js';
|
|
6
|
-
const EXTENSOES_COM_AST = new Set([
|
|
7
|
-
'.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs',
|
|
8
|
-
'.css', '.scss', '.html', '.xml', '.svg',
|
|
9
|
-
'.py', '.go', '.rs', '.php', '.sh',
|
|
10
|
-
'.yaml', '.yml', '.json',
|
|
11
|
-
]);
|
|
12
|
-
function extensaoRelevante(relPath) {
|
|
13
|
-
const ext = path.extname(relPath).toLowerCase();
|
|
14
|
-
return EXTENSOES_COM_AST.has(ext);
|
|
15
|
-
}
|
|
16
|
-
async function carregarTecnicas() {
|
|
17
|
-
const { registroAnalistas } = await import('../analysts/registry/index.js');
|
|
18
|
-
return asTecnicas(registroAnalistas);
|
|
19
|
-
}
|
|
20
|
-
function tecnicasParaArquivo(tecnicas, relPath) {
|
|
21
|
-
return tecnicas.filter(t => {
|
|
22
|
-
if (t.global) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
if (!t.test) {
|
|
26
|
-
return extensaoRelevante(relPath);
|
|
27
|
-
}
|
|
28
|
-
return t.test(relPath);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
const AST_SENTINEL = {};
|
|
32
|
-
export async function analyzeFile(filePath, content, baseDir) {
|
|
33
|
-
const inicio = performance.now();
|
|
34
|
-
const relPath = baseDir ? path.relative(baseDir, filePath) : path.basename(filePath);
|
|
35
|
-
if (!extensaoRelevante(relPath)) {
|
|
36
|
-
return { ocorrencias: [], arquivo: relPath, tempoMs: 0 };
|
|
37
|
-
}
|
|
38
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
39
|
-
const parsed = await decifrarSintaxe(content, ext, { relPath });
|
|
40
|
-
const ast = parsed ? AST_SENTINEL : null;
|
|
41
|
-
const tecnicas = await carregarTecnicas();
|
|
42
|
-
const tecnicasFile = tecnicasParaArquivo(tecnicas, relPath);
|
|
43
|
-
if (tecnicasFile.length === 0) {
|
|
44
|
-
return { ocorrencias: [], arquivo: relPath, tempoMs: performance.now() - inicio };
|
|
45
|
-
}
|
|
46
|
-
const ocorrencias = [];
|
|
47
|
-
for (const tecnica of tecnicasFile) {
|
|
48
|
-
try {
|
|
49
|
-
const resultado = await tecnica.aplicar(content, relPath, ast, filePath);
|
|
50
|
-
if (Array.isArray(resultado)) {
|
|
51
|
-
ocorrencias.push(...resultado);
|
|
52
|
-
}
|
|
53
|
-
else if (resultado) {
|
|
54
|
-
ocorrencias.push(resultado);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
// Silencia erros por analista
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
ocorrencias,
|
|
63
|
-
arquivo: relPath,
|
|
64
|
-
tempoMs: performance.now() - inicio,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export async function analyzeProject(projectDir, opts) {
|
|
68
|
-
const inicio = performance.now();
|
|
69
|
-
const fileEntries = await scanRepository(projectDir, {
|
|
70
|
-
includeContent: true,
|
|
71
|
-
});
|
|
72
|
-
const entries = Object.values(fileEntries);
|
|
73
|
-
const fileEntriesComAst = entries.map(f => ({ ...f, ast: undefined }));
|
|
74
|
-
let filteredEntries = fileEntriesComAst;
|
|
75
|
-
if (opts?.fast) {
|
|
76
|
-
filteredEntries = fileEntriesComAst.filter(fe => {
|
|
77
|
-
const rel = fe.relPath || '';
|
|
78
|
-
return !rel.includes('node_modules') && !rel.includes('.test.') && !rel.includes('.spec.');
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
const tecnicas = await carregarTecnicas();
|
|
82
|
-
const resultadoExecucao = await executarInquisicao(filteredEntries, tecnicas, projectDir, null, { verbose: false, compact: true, fast: opts?.fast });
|
|
83
|
-
return {
|
|
84
|
-
ocorrencias: resultadoExecucao.ocorrencias,
|
|
85
|
-
totalArquivos: entries.length,
|
|
86
|
-
tempoMs: performance.now() - inicio,
|
|
87
|
-
};
|
|
88
|
-
}
|
package/dist/sdk/index.js
DELETED
package/dist/sdk/sdk-legacy.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
import { analistaGithubActions, analistaGithubActionsGlobal, registrarDetectorGithubActions } from '../analysts/github-actions/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Mahoraga SDK Principal
|
|
5
|
-
* Fornece acesso programático aos analistas e sistema de plugins
|
|
6
|
-
*/
|
|
7
|
-
export const MahoragaSDK = {
|
|
8
|
-
/**
|
|
9
|
-
* Analisa um conteúdo de workflow individual
|
|
10
|
-
*/
|
|
11
|
-
async analisarGithubActions(conteudo, relPath = '.github/workflows/main.yml') {
|
|
12
|
-
try {
|
|
13
|
-
const res = await analistaGithubActions.aplicar(conteudo, relPath, null, undefined, undefined);
|
|
14
|
-
return Array.isArray(res) ? res : [];
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
/**
|
|
21
|
-
* Analisa um repositório completo (Contexto global)
|
|
22
|
-
*/
|
|
23
|
-
async analisarRepositorio(contexto) {
|
|
24
|
-
try {
|
|
25
|
-
const res = await analistaGithubActionsGlobal.aplicar('', '', null, undefined, contexto);
|
|
26
|
-
return Array.isArray(res) ? res : [];
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Registra um novo plugin de detector
|
|
34
|
-
*/
|
|
35
|
-
registrarDetector: registrarDetectorGithubActions
|
|
36
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/sdk/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './analyzer.js';
|