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

[DEV] adding parse flags function #38

Merged
merged 1 commit into from
Jul 22, 2022
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
9 changes: 8 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9867,12 +9867,18 @@ async function generateGithubReportFile(token) {
reject(err);
});
}
;// 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(' ', '='));
}
;// CONCATENATED MODULE: ./src/index.js






const target = core.getInput('target', { required: false });
const urls = core.getInput('urls', { required: false });
const templates = core.getInput('templates', { required: false });
Expand Down Expand Up @@ -9925,11 +9931,12 @@ async function run() {
if (reportConfig) params.push(`-rc=${reportConfig}`);
if (config) params.push(`-config=${config}`);
if (userAgent) params.push(`-H=${userAgent}`);
if (flags) params.push(flags);
params.push(`-o=${ output ? output : 'nuclei.log' }`);
if (src_json) params.push('-json');
if (includeRR) params.push('-irr');

if (flags) params.push(...parseFlagsToArray(flags));

// If everything is fine and github-report is set, generate the yaml config file.
if (githubRepot) {
await generateGithubReportFile(githubToken);
Expand Down
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as installer from './installer';
import { generateGithubReportFile } from './yaml';
import { parseFlagsToArray } from './utils';

const target = core.getInput('target', { required: false });
const urls = core.getInput('urls', { required: false });
Expand Down Expand Up @@ -55,11 +56,12 @@ async function run() {
if (reportConfig) params.push(`-rc=${reportConfig}`);
if (config) params.push(`-config=${config}`);
if (userAgent) params.push(`-H=${userAgent}`);
if (flags) params.push(flags);
params.push(`-o=${ output ? output : 'nuclei.log' }`);
if (json) params.push('-json');
if (includeRR) params.push('-irr');

if (flags) params.push(...parseFlagsToArray(flags));

// If everything is fine and github-report is set, generate the yaml config file.
if (githubRepot) {
await generateGithubReportFile(githubToken);
Expand Down
4 changes: 4 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
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(' ', '='));
}