Skip to content

Commit

Permalink
Lint fixes (#1363)
Browse files Browse the repository at this point in the history
* Lint fixes

Signed-off-by: Prabhu Subramanian <[email protected]>

* Lint fixes

Signed-off-by: Prabhu Subramanian <[email protected]>

* Added pixi repo tests

Signed-off-by: Prabhu Subramanian <[email protected]>

---------

Signed-off-by: Prabhu Subramanian <[email protected]>
  • Loading branch information
prabhu authored Sep 8, 2024
1 parent 38cd3df commit 806d212
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 52 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/repotests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,15 @@ jobs:
run: |
bin/cdxgen.js -t python repotests/impacket -o bomresults/impacket.json
shell: bash
- name: repotests pixi
run: |
mkdir pixi-sample
cd pixi-sample
curl -LO https://raw.githubusercontent.com/prefix-dev/pixi/main/pixi.lock
curl -LO https://raw.githubusercontent.com/prefix-dev/pixi/main/pixi.toml
cd ..
bin/cdxgen.js -t python pixi-sample -o bomresults/bom-pixi.json -p
shell: bash
- name: repotests shiftleft-java-example
run: |
bin/cdxgen.js -p -r -t java repotests/shiftleft-java-example -o bomresults/bom-java.json --generate-key-and-sign
Expand Down Expand Up @@ -506,14 +515,6 @@ jobs:
run: |
ls -ltr bomresults
shell: bash
- name: buntests
run: |
rm -rf node_modules
bun install
bun --bun bin/cdxgen.js -p -t java repotests/java-sec-code -o bomresults/bom-java-sec-code-bun.json --deep
bun --bun bin/cdxgen.js -p -t python repotests/django-DefectDojo -o bomresults/django-DefectDojo-bun.json
continue-on-error: true
shell: bash
- name: denotests
run: |
rm -rf node_modules
Expand All @@ -524,6 +525,14 @@ jobs:
env:
FETCH_LICENSE: true
shell: bash
- name: buntests
run: |
rm -rf node_modules
bun install
bun --bun bin/cdxgen.js -p -t java repotests/java-sec-code -o bomresults/bom-java-sec-code-bun.json --deep
bun --bun bin/cdxgen.js -p -t python repotests/django-DefectDojo -o bomresults/django-DefectDojo-bun.json
continue-on-error: true
shell: bash
- uses: actions/upload-artifact@v4
if: github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest'
with:
Expand Down
10 changes: 6 additions & 4 deletions analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ const getAllFiles = (deep, dir, extn, files, result, regex) => {
result,
regex,
);
} catch (error) {}
} catch (error) {
// ignore
}
} else {
if (regex.test(file)) {
result.push(file);
Expand Down Expand Up @@ -197,16 +199,16 @@ const fileToParseableCode = (file) => {
)
.replace(
vueBindRegex,
(match, grA, grB, grC) =>
(_match, grA, grB, grC) =>
grA.replaceAll(/\S/g, " ") + grB + grC.replaceAll(/\S/g, " "),
)
.replace(
vuePropRegex,
(match, grA, grB) => ` ${grA.replace(/[.:@]/g, " ")}${grB}`,
(_match, grA, grB) => ` ${grA.replace(/[.:@]/g, " ")}${grB}`,
)
.replace(
vueTemplateRegex,
(match, grA, grB, grC) =>
(_match, grA, grB, grC) =>
grA + grB.replaceAll("{{", "{ ").replaceAll("}}", " }") + grC,
);
}
Expand Down
27 changes: 23 additions & 4 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,40 @@
},
"linter": {
"enabled": true,
"ignore": ["types/**"],
"ignore": ["types/**", "contrib/**"],
"rules": {
"recommended": true,
"complexity": {
"noForEach": "off",
"useLiteralKeys": "off"
"useLiteralKeys": "off",
"noUselessTernary": "warn"
},
"correctness": {
"noUndeclaredVariables": "error",
"noUnnecessaryContinue": "warn",
"noConstAssign": "error",
"noConstantCondition": "error",
"noUnreachable": "info"
},
"performance": {
"noDelete": "off"
},
"style": {
"noParameterAssign": "off"
"noParameterAssign": "off",
"noShoutyConstants": "warn",
"noUselessElse": "warn"
},
"suspicious": {
"noAssignInExpressions": "off"
"noAssignInExpressions": "off",
"noDoubleEquals": "warn",
"noAsyncPromiseExecutor": "warn",
"noControlCharactersInRegex": "warn",
"noDebugger": "error",
"noEmptyBlockStatements": "warn"
},
"nursery": {
"noUnusedFunctionParameters": "warn",
"noDuplicateElseIf": "warn"
}
}
},
Expand Down
12 changes: 9 additions & 3 deletions docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,9 @@ export const extractTar = async (fullImageName, dir) => {
strict: true,
C: dir,
portable: true,
onwarn: () => {},
onwarn: () => {
// ignore
},
filter: (path, entry) => {
// Some files are known to cause issues with extract
if (
Expand Down Expand Up @@ -1078,7 +1080,9 @@ export const exportImage = async (fullImageName) => {
strict: true,
C: tempDir,
portable: true,
onwarn: () => {},
onwarn: () => {
// ignore
},
}),
);
} catch (err) {
Expand All @@ -1095,7 +1099,9 @@ export const exportImage = async (fullImageName) => {
strict: true,
C: tempDir,
portable: true,
onwarn: () => {},
onwarn: () => {
// ignore
},
}),
);
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion envcontext.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function getOriginUrl(dir) {
*
* @returns Output from git config or undefined
*/
export function getBranch(configKey, dir) {
export function getBranch(_configKey, dir) {
return execGitCommand(dir, ["rev-parse", "--abbrev-ref", "HEAD"]);
}

Expand Down
6 changes: 3 additions & 3 deletions evinser.js
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ export const detectServicesFromUDT = (
}
};

export const constructServiceName = (language, slice) => {
export const constructServiceName = (_language, slice) => {
let serviceName = "service";
if (slice?.fullName) {
serviceName = slice.fullName.split(":")[0].replace(/\./g, "-");
Expand Down Expand Up @@ -1149,7 +1149,7 @@ export const collectDataFlowFrames = async (
userDefinedTypesMap,
dataFlowSlice,
dbObjMap,
purlLocationMap,
_purlLocationMap,
purlImportsMap,
) => {
const nodes = dataFlowSlice?.graph?.nodes || [];
Expand Down Expand Up @@ -1268,7 +1268,7 @@ export const collectDataFlowFrames = async (
* @param {string} language Application language
* @param {Object} reachablesSlice Reachables slice object from atom
*/
export const collectReachableFrames = (language, reachablesSlice) => {
export const collectReachableFrames = (_language, reachablesSlice) => {
const reachableNodes = reachablesSlice?.reachables || [];
// purl key and an array of frames array
// CycloneDX 1.5 currently accepts only 1 frame as evidence
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
executeParallelGradleProperties,
extractJarArchive,
frameworksList,
generatePixiLockFile,
getAllFiles,
getCppModules,
getGradleCommand,
Expand Down Expand Up @@ -4268,7 +4269,7 @@ export function createCloudBuildBom(path, options) {
* @param {string} path to the project
* @param {Object} options Parse options from the cli
*/
export function createOSBom(path, options) {
export function createOSBom(_path, options) {
console.warn(
"About to generate OBOM for the current OS installation. This will take several minutes ...",
);
Expand Down
4 changes: 2 additions & 2 deletions postgen.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function postProcess(bomNSData, options) {
*
* @returns {Object} Filtered BOM JSON
*/
export function applyMetadata(bomJson, options) {
export function applyMetadata(bomJson, _options) {
if (!bomJson?.components) {
return bomJson;
}
Expand Down Expand Up @@ -265,7 +265,7 @@ export function filterBom(bomJson, options) {
/**
* Clean up
*/
export function cleanupEnv(options) {
export function cleanupEnv(_options) {
if (process.env?.PIP_TARGET?.startsWith(tmpdir())) {
rmSync(process.env.PIP_TARGET, { recursive: true, force: true });
}
Expand Down
2 changes: 1 addition & 1 deletion pregen.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export function prepareSdkmanBuild(projectType) {
* @param {String} filePath Path
* @param {Object} options CLI Options
*/
export function preparePythonEnv(filePath, options) {
export function preparePythonEnv(_filePath, options) {
if (hasAnyProjectType("python", options, false)) {
if (arch() !== "x64") {
console.log(
Expand Down
2 changes: 1 addition & 1 deletion types/analyzer.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/docker.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/envcontext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function getOriginUrl(dir: string): any;
*
* @returns Output from git config or undefined
*/
export function getBranch(configKey: string, dir: string): any;
export function getBranch(_configKey: any, dir: string): any;
/**
* Retrieves the tree and parent hash for a git repo
* @param {string} dir repo directory
Expand Down
2 changes: 1 addition & 1 deletion types/envcontext.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions types/evinser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,11 @@ export function parseSliceUsages(language: string, userDefinedTypesMap: any, sli
export function isFilterableType(language: any, userDefinedTypesMap: any, typeFullName: any): boolean;
export function detectServicesFromUsages(language: string, slice: any, servicesMap?: any): any[];
export function detectServicesFromUDT(language: string, userDefinedTypes: any[], servicesMap: any): void;
export function constructServiceName(language: any, slice: any): string;
export function constructServiceName(_language: any, slice: any): string;
export function extractEndpoints(language: any, code: any): any;
export function createEvinseFile(sliceArtefacts: any, options: any): any;
export function collectDataFlowFrames(language: string, userDefinedTypesMap: any, dataFlowSlice: any, dbObjMap: any, purlLocationMap: any, purlImportsMap: any): Promise<{}>;
export function collectReachableFrames(language: string, reachablesSlice: any): {
export function collectDataFlowFrames(language: string, userDefinedTypesMap: any, dataFlowSlice: any, dbObjMap: any, _purlLocationMap: any, purlImportsMap: any): Promise<{}>;
export function collectReachableFrames(_language: any, reachablesSlice: any): {
dataFlowFrames: {};
cryptoComponents: {
type: string;
Expand Down
2 changes: 1 addition & 1 deletion types/evinser.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function createCloudBuildBom(path: string, options: any): any;
* @param {string} path to the project
* @param {Object} options Parse options from the cli
*/
export function createOSBom(path: string, options: any): Promise<any>;
export function createOSBom(_path: any, options: any): Promise<any>;
/**
* Function to create bom string for Jenkins plugins
*
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions types/postgen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function postProcess(bomNSData: any, options: any): any;
*
* @returns {Object} Filtered BOM JSON
*/
export function applyMetadata(bomJson: any, options: any): any;
export function applyMetadata(bomJson: any, _options: any): any;
/**
* Apply definitions.standards based on options
*
Expand All @@ -37,5 +37,5 @@ export function filterBom(bomJson: any, options: any): any;
/**
* Clean up
*/
export function cleanupEnv(options: any): void;
export function cleanupEnv(_options: any): void;
//# sourceMappingURL=postgen.d.ts.map
2 changes: 1 addition & 1 deletion types/postgen.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion types/pregen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function prepareSdkmanBuild(projectType: string): boolean;
* @param {String} filePath Path
* @param {Object} options CLI Options
*/
export function preparePythonEnv(filePath: string, options: any): void;
export function preparePythonEnv(_filePath: any, options: any): void;
/**
* Method to check and prepare the environment for node
*
Expand Down
Loading

0 comments on commit 806d212

Please sign in to comment.