Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix undefined replace func errors #88

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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