Skip to content

Commit

Permalink
huntr - Command Injection Fix (#18)
Browse files Browse the repository at this point in the history
Co-authored-by: jammy <[email protected]>
Co-authored-by: Paweł Trysła <[email protected]>
  • Loading branch information
3 people authored Apr 7, 2020
1 parent e1e2296 commit ef2f673
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/android/adb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { spawn, execSync, ChildProcess } from 'child_process';
import { spawn, execFileSync, ChildProcess } from 'child_process';
import path from 'path';
import {
CodeError,
Expand All @@ -25,7 +25,7 @@ export function getAdbPath(customPath?: string): string {

export function spawnLogcatProcess(adbPath: string): ChildProcess {
try {
execSync(`${adbPath} logcat -c`);
execFileSync(adbPath, ['logcat', '-c']);
} catch (error) {
throw new CodeError(
ERR_ANDROID_CANNOT_CLEAN_LOGCAT_BUFFER,
Expand All @@ -49,11 +49,14 @@ export function getApplicationPid(
applicationId: string,
adbPath?: string
): number {
let output: Buffer | undefined;
let output: Buffer | String | undefined;
try {
output = execSync(
`'${getAdbPath(adbPath)}' shell pidof -s ${applicationId}`
);
output = execFileSync(getAdbPath(adbPath), [
'shell',
'pidof',
'-s',
applicationId,
]);
} catch (error) {
throw new CodeError(
ERR_ANDROID_CANNOT_GET_APP_PID,
Expand Down

0 comments on commit ef2f673

Please sign in to comment.