Skip to content

Commit

Permalink
fix undefined replace func errors (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanaReddy0M authored Jul 25, 2024
1 parent dcaa7d0 commit 54dad06
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
19 changes: 16 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');

Expand Down Expand Up @@ -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 = {};
Expand Down Expand Up @@ -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


Expand Down
4 changes: 4 additions & 0 deletions src/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');

Expand Down
8 changes: 6 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -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(' ', '='));
}
const matches = rawFlags.match(re);
if (!matches) {
return [];
}
return matches.map(token => token.trim()).map(token => token.replace(' ', '='));
}
8 changes: 6 additions & 2 deletions src/yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand Down

0 comments on commit 54dad06

Please sign in to comment.