@stackaid/stackaid-json-generator
Advanced tools
@@ -1,6 +0,3 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.DEPENDENCY_FILE_TYPES = exports.SUMMARY_FILE_TYPES = exports.FileTypes = exports.GITHUB_DOMAIN = void 0; | ||
| exports.GITHUB_DOMAIN = 'github.com'; | ||
| exports.FileTypes = { | ||
| export const GITHUB_DOMAIN = 'github.com'; | ||
| export const FileTypes = { | ||
| go: ['go.mod'], | ||
@@ -14,9 +11,9 @@ java: ['pom.xml'], | ||
| }; | ||
| exports.SUMMARY_FILE_TYPES = Object.values(exports.FileTypes).flat(); | ||
| exports.DEPENDENCY_FILE_TYPES = [ | ||
| exports.FileTypes.java, | ||
| exports.FileTypes.php, | ||
| exports.FileTypes.python, | ||
| exports.FileTypes.ruby, | ||
| exports.FileTypes.rust, | ||
| export const SUMMARY_FILE_TYPES = Object.values(FileTypes).flat(); | ||
| export const DEPENDENCY_FILE_TYPES = [ | ||
| FileTypes.java, | ||
| FileTypes.php, | ||
| FileTypes.python, | ||
| FileTypes.ruby, | ||
| FileTypes.rust, | ||
| ].flat(); |
+11
-40
@@ -1,38 +0,9 @@ | ||
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.generators = void 0; | ||
| const go = __importStar(require("./go.js")); | ||
| const lodash_1 = __importDefault(require("lodash")); | ||
| const path_1 = __importDefault(require("path")); | ||
| const constants_js_1 = require("./constants.js"); | ||
| const queries_js_1 = require("./queries.js"); | ||
| const { uniqBy } = lodash_1.default; | ||
| import * as go from './go.js'; | ||
| import lodash from 'lodash'; | ||
| import path from 'path'; | ||
| import { GITHUB_DOMAIN } from './constants.js'; | ||
| import { getClient } from './queries.js'; | ||
| const { uniqBy } = lodash; | ||
| const getJavaScriptDependencies = async ({ octokit, owner, repo, filename, }) => { | ||
| const content = await (0, queries_js_1.getClient)(octokit).getFileContents(owner, repo, filename); | ||
| const content = await getClient(octokit).getFileContents(owner, repo, filename); | ||
| const { dependencies, devDependencies } = JSON.parse(content); | ||
@@ -42,5 +13,5 @@ return { filename, dependencies, devDependencies }; | ||
| const getGoDependencies = async ({ owner, repo, filename, sourceDir, }) => { | ||
| const parent = `https://${constants_js_1.GITHUB_DOMAIN}/${owner}/${repo}`; | ||
| const parent = `https://${GITHUB_DOMAIN}/${owner}/${repo}`; | ||
| const deps = go | ||
| .getDependencies(path_1.default.dirname(filename), sourceDir) | ||
| .getDependencies(path.dirname(filename), sourceDir) | ||
| .filter(({ source }) => source !== parent); | ||
@@ -50,3 +21,3 @@ return deps; | ||
| const getDependencyGraph = async ({ octokit, owner, repo, after, }) => { | ||
| const client = (0, queries_js_1.getClient)(octokit); | ||
| const client = getClient(octokit); | ||
| const dependencies = []; | ||
@@ -70,3 +41,3 @@ const results = await client.getRepositoryDependencies(owner, repo, 1, after); | ||
| }; | ||
| exports.generators = { | ||
| export const generators = { | ||
| go: getGoDependencies, | ||
@@ -73,0 +44,0 @@ javascript: getJavaScriptDependencies, |
+15
-24
@@ -1,16 +0,10 @@ | ||
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getDependencies = exports.getModuleGraph = exports.listDirectDeps = void 0; | ||
| const lodash_1 = __importDefault(require("lodash")); | ||
| const path_1 = __importDefault(require("path")); | ||
| const constants_js_1 = require("./constants.js"); | ||
| const child_process_1 = require("child_process"); | ||
| const { uniqBy } = lodash_1.default; | ||
| const filterDependency = (line) => line.startsWith(constants_js_1.GITHUB_DOMAIN); | ||
| import lodash from 'lodash'; | ||
| import path from 'path'; | ||
| import { GITHUB_DOMAIN } from './constants.js'; | ||
| import { execSync } from 'child_process'; | ||
| const { uniqBy } = lodash; | ||
| const filterDependency = (line) => line.startsWith(GITHUB_DOMAIN); | ||
| const parseDependency = (line) => { | ||
| switch (true) { | ||
| case line.startsWith(constants_js_1.GITHUB_DOMAIN): | ||
| case line.startsWith(GITHUB_DOMAIN): | ||
| const [domain, owner, repo] = line.split('/'); | ||
@@ -27,4 +21,4 @@ return `https://${domain}/${owner}/${repo}`; | ||
| }; | ||
| const listDirectDeps = (dir, sourceDir) => { | ||
| let output = (0, child_process_1.execSync)(`go list -f '{{if not .Indirect}}{{.}}{{end}}' -m all`, { cwd: path_1.default.resolve(sourceDir, dir) }).toString(); | ||
| export const listDirectDeps = (dir, sourceDir) => { | ||
| let output = execSync(`go list -f '{{if not .Indirect}}{{.}}{{end}}' -m all`, { cwd: path.resolve(sourceDir, dir) }).toString(); | ||
| return output | ||
@@ -38,6 +32,5 @@ .split('\n') | ||
| }; | ||
| exports.listDirectDeps = listDirectDeps; | ||
| const getModuleGraph = (dir, sourceDir) => { | ||
| const output = (0, child_process_1.execSync)(`go mod graph`, { | ||
| cwd: path_1.default.resolve(sourceDir, dir), | ||
| export const getModuleGraph = (dir, sourceDir) => { | ||
| const output = execSync(`go mod graph`, { | ||
| cwd: path.resolve(sourceDir, dir), | ||
| }).toString(); | ||
@@ -63,6 +56,5 @@ const graph = {}; | ||
| }; | ||
| exports.getModuleGraph = getModuleGraph; | ||
| const getDependencies = (dir = '', sourceDir = process.cwd()) => { | ||
| const graph = (0, exports.getModuleGraph)(dir, sourceDir); | ||
| const direct = (0, exports.listDirectDeps)(dir, sourceDir); | ||
| export const getDependencies = (dir = '', sourceDir = process.cwd()) => { | ||
| const graph = getModuleGraph(dir, sourceDir); | ||
| const direct = listDirectDeps(dir, sourceDir); | ||
| let dependencies = direct | ||
@@ -84,2 +76,1 @@ .filter((d) => filterDependency(d.module)) | ||
| }; | ||
| exports.getDependencies = getDependencies; |
+11
-39
@@ -1,44 +0,17 @@ | ||
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getDependencies = exports.generators = void 0; | ||
| const core = __importStar(require("@actions/core")); | ||
| const constants_js_1 = require("./constants.js"); | ||
| const generate_js_1 = require("./generate.js"); | ||
| const queries_js_1 = require("./queries.js"); | ||
| const utils_js_1 = require("./utils.js"); | ||
| var generate_js_2 = require("./generate.js"); | ||
| Object.defineProperty(exports, "generators", { enumerable: true, get: function () { return generate_js_2.generators; } }); | ||
| const getDependencies = async (config, generatorTypes) => { | ||
| import * as core from '@actions/core'; | ||
| import { FileTypes } from './constants.js'; | ||
| import { generators } from './generate.js'; | ||
| import { getClient } from './queries.js'; | ||
| import { isFileType } from './utils.js'; | ||
| export { generators } from './generate.js'; | ||
| export const getDependencies = async (config, generatorTypes) => { | ||
| const { owner, repo, octokit } = config; | ||
| const packageJson = []; | ||
| const stackAidJson = { version: 1, dependencies: [] }; | ||
| const client = (0, queries_js_1.getClient)(octokit); | ||
| const client = getClient(octokit); | ||
| const summary = await client.getRepositorySummary(owner, repo, '**/'); | ||
| const generate = { ...generate_js_1.generators, ...generatorTypes }; | ||
| const generate = { ...generators, ...generatorTypes }; | ||
| for (const { after, node: { filename }, } of summary) { | ||
| switch (true) { | ||
| case (0, utils_js_1.isFileType)(filename, constants_js_1.FileTypes.go): { | ||
| case isFileType(filename, FileTypes.go): { | ||
| core.info(`Found ${filename}, getting Go dependencies`); | ||
@@ -49,3 +22,3 @@ const deps = await generate.go({ ...config, filename }); | ||
| } | ||
| case (0, utils_js_1.isFileType)(filename, constants_js_1.FileTypes.javascript): { | ||
| case isFileType(filename, FileTypes.javascript): { | ||
| core.info(`Found ${filename}, copying dependencies`); | ||
@@ -66,2 +39,1 @@ const deps = await generate.javascript({ ...config, filename }); | ||
| }; | ||
| exports.getDependencies = getDependencies; |
+13
-20
@@ -1,14 +0,8 @@ | ||
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getClient = exports.repositoryFragment = exports.summaryFragment = void 0; | ||
| const lodash_1 = __importDefault(require("lodash")); | ||
| const constants_js_1 = require("./constants.js"); | ||
| const graphql_tag_1 = require("graphql-tag"); | ||
| const utils_js_1 = require("./utils.js"); | ||
| const graphql_1 = require("graphql"); | ||
| const { uniqBy } = lodash_1.default; | ||
| exports.summaryFragment = (0, graphql_tag_1.gql)(` | ||
| import lodash from 'lodash'; | ||
| import { DEPENDENCY_FILE_TYPES, SUMMARY_FILE_TYPES } from './constants.js'; | ||
| import { gql } from 'graphql-tag'; | ||
| import { matches } from './utils.js'; | ||
| import { print } from 'graphql'; | ||
| const { uniqBy } = lodash; | ||
| export const summaryFragment = gql(` | ||
| fragment summaryFragment on DependencyGraphManifestConnection { | ||
@@ -24,3 +18,3 @@ edges { | ||
| `); | ||
| exports.repositoryFragment = (0, graphql_tag_1.gql)(` | ||
| export const repositoryFragment = gql(` | ||
| fragment repositoryFragment on DependencyGraphManifestConnection { | ||
@@ -47,3 +41,3 @@ nodes { | ||
| `); | ||
| const getClient = (octokit) => { | ||
| export const getClient = (octokit) => { | ||
| return { | ||
@@ -93,3 +87,3 @@ async graphql(query, variables) { | ||
| } | ||
| ${(0, graphql_1.print)(exports.summaryFragment)} | ||
| ${print(summaryFragment)} | ||
| `, { repo, owner, cursor })); | ||
@@ -118,3 +112,3 @@ const { dependencyGraphManifests: { edges }, } = result.repository; | ||
| })) | ||
| .filter((edge) => (0, utils_js_1.matches)(edge.node.filename, constants_js_1.SUMMARY_FILE_TYPES, glob)); | ||
| .filter((edge) => matches(edge.node.filename, SUMMARY_FILE_TYPES, glob)); | ||
| return relevant; | ||
@@ -141,7 +135,7 @@ }, | ||
| } | ||
| ${(0, graphql_1.print)(exports.repositoryFragment)} | ||
| ${print(repositoryFragment)} | ||
| `, { repo, owner, first, after })); | ||
| const { dependencyGraphManifests: { nodes }, } = result.repository; | ||
| const dependencies = uniqBy(nodes | ||
| .filter((n) => (0, utils_js_1.matches)(n.filename, constants_js_1.DEPENDENCY_FILE_TYPES)) | ||
| .filter((n) => matches(n.filename, DEPENDENCY_FILE_TYPES)) | ||
| .flatMap((n) => n.dependencies.nodes) | ||
@@ -197,2 +191,1 @@ .filter((d) => d.repository?.url), (d) => d.repository.url); | ||
| }; | ||
| exports.getClient = getClient; |
@@ -1,2 +0,1 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| export {}; |
+3
-11
@@ -1,11 +0,3 @@ | ||
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.isFileType = exports.matches = void 0; | ||
| const minimatch_1 = __importDefault(require("minimatch")); | ||
| const matches = (file, fileTypes, glob = '') => (0, minimatch_1.default)(file.toLowerCase(), `${glob}*(${fileTypes.join('|')})`); | ||
| exports.matches = matches; | ||
| const isFileType = (filename, fileType) => (0, exports.matches)(filename, fileType, '**/'); | ||
| exports.isFileType = isFileType; | ||
| import minimatch from 'minimatch'; | ||
| export const matches = (file, fileTypes, glob = '') => minimatch(file.toLowerCase(), `${glob}*(${fileTypes.join('|')})`); | ||
| export const isFileType = (filename, fileType) => matches(filename, fileType, '**/'); |
+1
-1
| { | ||
| "name": "@stackaid/stackaid-json-generator", | ||
| "version": "1.9.0-11", | ||
| "version": "1.9.0-12", | ||
| "private": false, | ||
@@ -5,0 +5,0 @@ "description": "Generate a stackaid.json file based on your repository's dependency graph", |
Sorry, the diff of this file is too big to display
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2429479
-0.73%52212
-0.22%