diff --git a/dist/index.js b/dist/index.js index 399292e..ba805d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6846,6 +6846,10 @@ async function getLatestInfo() { async function downloadAndInstall(selectedVersion) { const toolName = "nuclei"; const latest = await getLatestInfo(); + + if (!latest || !latest.tag_name) { + throw new Error("Latest version information is not available."); + } const version = selectedVersion ? selectedVersion : latest.tag_name.replace(/v/g, ''); @@ -10744,15 +10748,19 @@ var external_path_ = __nccwpck_require__(1017); const GITHUB_ACTOR = process.env.GITHUB_ACTOR; const GITHUB_REPOSITORY_OWNER = process.env.GITHUB_REPOSITORY_OWNER; -const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY.replace(`${GITHUB_REPOSITORY_OWNER}/`, ''); +const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY; const GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE; async function generateGithubReportFile(token, reportConfigFileName = 'github-report.yaml') { + if (!GITHUB_REPOSITORY || !GITHUB_REPOSITORY_OWNER) { + throw new Error('GITHUB_REPOSITORY or GITHUB_REPOSITORY_OWNER is not set.'); + } + const projectName = GITHUB_REPOSITORY.replace(`${GITHUB_REPOSITORY_OWNER}/`, ''); const gitHubRepoConfig = { username: GITHUB_ACTOR, owner: GITHUB_REPOSITORY_OWNER, token, - "project-name": GITHUB_REPOSITORY, + "project-name": projectName, }; let content = {}; @@ -10780,8 +10788,13 @@ async function generateGithubReportFile(token, reportConfigFileName = 'github-re ;// CONCATENATED MODULE: ./src/utils.js function parseFlagsToArray(rawFlags) { const re = /(?:(?:^|\s)-[-a-z]+)(?:(?:\s|=)(?:[^-](?:[0-9a-z-\S])*))?/g; - return rawFlags.match(re).map(token => token.trim()).map(token => token.replace(' ', '=')); + const matches = rawFlags.match(re); + if (!matches) { + return []; + } + return matches.map(token => token.trim()).map(token => token.replace(' ', '=')); } + ;// CONCATENATED MODULE: ./src/index.js diff --git a/src/installer.js b/src/installer.js index b8a56e7..9cd2d0c 100644 --- a/src/installer.js +++ b/src/installer.js @@ -37,6 +37,10 @@ async function getLatestInfo() { export async function downloadAndInstall(selectedVersion) { const toolName = "nuclei"; const latest = await getLatestInfo(); + + if (!latest || !latest.tag_name) { + throw new Error("Latest version information is not available."); + } const version = selectedVersion ? selectedVersion : latest.tag_name.replace(/v/g, ''); diff --git a/src/utils.js b/src/utils.js index 86a773a..b32dc36 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,4 +1,8 @@ export function parseFlagsToArray(rawFlags) { const re = /(?:(?:^|\s)-[-a-z]+)(?:(?:\s|=)(?:[^-](?:[0-9a-z-\S])*))?/g; - return rawFlags.match(re).map(token => token.trim()).map(token => token.replace(' ', '=')); -} \ No newline at end of file + const matches = rawFlags.match(re); + if (!matches) { + return []; + } + return matches.map(token => token.trim()).map(token => token.replace(' ', '=')); +} diff --git a/src/yaml.js b/src/yaml.js index d148a50..b253f70 100644 --- a/src/yaml.js +++ b/src/yaml.js @@ -4,15 +4,19 @@ import * as path from 'path'; const GITHUB_ACTOR = process.env.GITHUB_ACTOR; const GITHUB_REPOSITORY_OWNER = process.env.GITHUB_REPOSITORY_OWNER; -const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY.replace(`${GITHUB_REPOSITORY_OWNER}/`, ''); +const GITHUB_REPOSITORY = process.env.GITHUB_REPOSITORY; const GITHUB_WORKSPACE = process.env.GITHUB_WORKSPACE; export async function generateGithubReportFile(token, reportConfigFileName = 'github-report.yaml') { + if (!GITHUB_REPOSITORY || !GITHUB_REPOSITORY_OWNER) { + throw new Error('GITHUB_REPOSITORY or GITHUB_REPOSITORY_OWNER is not set.'); + } + const projectName = GITHUB_REPOSITORY.replace(`${GITHUB_REPOSITORY_OWNER}/`, ''); const gitHubRepoConfig = { username: GITHUB_ACTOR, owner: GITHUB_REPOSITORY_OWNER, token, - "project-name": GITHUB_REPOSITORY, + "project-name": projectName, }; let content = {};