Skip to content
Open
Show file tree
Hide file tree
Changes from 7 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
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
rustup default stable
cargo install wasm-pack
- run: npm install
- run: npm run build
- run: BUILD_KEEP_STRUCTURE=true npm run build
- name: Run NoSQL Injection Benchmark
run: cd benchmarks/nosql-injection && AIKIDO_CI=true node benchmark.js
- name: Run SQL Injection Benchmark
Expand Down
4 changes: 2 additions & 2 deletions library/agent/hooks/onInspectionInterceptorResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { resolve } from "path";
import { cleanupStackTrace } from "../../helpers/cleanupStackTrace";
import { escapeHTML } from "../../helpers/escapeHTML";
import type { Agent } from "../Agent";
Expand All @@ -8,9 +7,10 @@ import { getContext, updateContext } from "../Context";
import type { InterceptorResult } from "./InterceptorResult";
import type { PartialWrapPackageInfo } from "./WrapPackageInfo";
import { cleanError } from "../../helpers/cleanError";
import { getLibraryRoot } from "../../helpers/getLibraryRoot";

// Used for cleaning up the stack trace
const libraryRoot = resolve(__dirname, "../..");
const libraryRoot = getLibraryRoot();

export function onInspectionInterceptorResult(
context: ReturnType<typeof getContext>,
Expand Down
5 changes: 3 additions & 2 deletions library/helpers/getAgentVersion.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { resolve } from "path";
import { join } from "path";
import { getLibraryRoot } from "./getLibraryRoot";

export function getAgentVersion(): string {
try {
const json = require(resolve(__dirname, "../package.json"));
const json = require(join(getLibraryRoot(), "package.json"));

/* c8 ignore start */
if (!json.version) {
Expand Down
6 changes: 4 additions & 2 deletions library/helpers/getLibraryRoot.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { resolve } from "path";
import { sep, resolve } from "path";

const libraryRoot = resolve(__dirname, "..");
const isBundled = !__filename.includes(`${sep}helpers${sep}getLibraryRoot`);

const libraryRoot = resolve(__dirname, isBundled ? "." : "..");

export function getLibraryRoot(): string {
return libraryRoot;
Expand Down
6 changes: 4 additions & 2 deletions library/helpers/isLibBundled.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { sep } from "path";

// Detect at runtime if the library is bundled inside an application
export function isLibBundled(): boolean {
// Replace Windows backslashes with forward slashes
const normalizedDirName = __dirname.replace(/\\/g, "/");

return (
!normalizedDirName.includes("node_modules/@aikidosec/firewall/helpers") &&
!normalizedDirName.includes("firewall-node/build/helpers") // In case of e2e tests
!normalizedDirName.includes(`node_modules${sep}@aikidosec${sep}firewall`) &&
!normalizedDirName.includes(`firewall-node${sep}build`) // In case of e2e tests
);
}
Loading