Skip to content

Commit

Permalink
Group all patches into one task
Browse files Browse the repository at this point in the history
  • Loading branch information
niklashigi committed Jan 14, 2021
1 parent 7c9d76f commit 4dee138
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 22 deletions.
25 changes: 3 additions & 22 deletions src/patch-apk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import chalk from 'chalk'

import { TaskOptions } from './cli'
import downloadTools from './tasks/download-tools'
import modifyManifest from './tasks/modify-manifest'
import createNetworkSecurityConfig from './tasks/create-netsec-config'
import disableCertificatePinning from './tasks/disable-certificate-pinning'
import observeAsync from './utils/observe-async'
import applyPatches from './tasks/apply-patches'

export default function patchApk(taskOptions: TaskOptions) {
const {
Expand All @@ -36,25 +34,8 @@ export default function patchApk(taskOptions: TaskOptions) {
task: () => apktool.decode(inputPath, decodeDir),
},
{
title: 'Modifying app manifest',
task: async context => {
const result = await modifyManifest(
path.join(decodeDir, 'AndroidManifest.xml'),
)

context.usesAppBundle = result.usesAppBundle
},
},
{
title: 'Replacing network security config',
task: () =>
createNetworkSecurityConfig(
path.join(decodeDir, `res/xml/nsc_mitm.xml`),
),
},
{
title: 'Disabling certificate pinning',
task: (_, task) => disableCertificatePinning(decodeDir, task),
title: 'Applying patches',
task: () => applyPatches(decodeDir),
},
{
title: 'Waiting for you to make changes',
Expand Down
32 changes: 32 additions & 0 deletions src/tasks/apply-patches.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as path from 'path'
import Listr from 'listr'

import modifyManifest from './modify-manifest'
import createNetworkSecurityConfig from './create-netsec-config'
import disableCertificatePinning from './disable-certificate-pinning'

export default function applyPatches(decodeDir: string) {
return new Listr([
{
title: 'Modifying app manifest',
task: async context => {
const result = await modifyManifest(
path.join(decodeDir, 'AndroidManifest.xml'),
)

context.usesAppBundle = result.usesAppBundle
},
},
{
title: 'Replacing network security config',
task: () =>
createNetworkSecurityConfig(
path.join(decodeDir, `res/xml/nsc_mitm.xml`),
),
},
{
title: 'Disabling certificate pinning',
task: (_, task) => disableCertificatePinning(decodeDir, task),
},
])
}

0 comments on commit 4dee138

Please sign in to comment.