Skip to content

Commit

Permalink
Fixed Parsing Issues for Folders
Browse files Browse the repository at this point in the history
  • Loading branch information
amrudesh-cred committed May 13, 2024
1 parent 935de16 commit cbe4240
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions apk/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"morf/models"
"morf/utils"
"os"
"os/exec"
"path/filepath"
"strings"

log "github.com/sirupsen/logrus"
alf "github.com/spf13/afero"
)

Expand All @@ -52,7 +52,6 @@ func StartMetaDataCollection(apkPath string) models.MetaDataModel {
// Move APK to input directory
apkPath = utils.CopyApktoInputDir(fs, apkPath)
fmt.Println("Starting metadata collection for " + apkPath)

metadata_success, metadata_error := exec.Command("java", "-cp", "tools/apkanalyzer.jar", "sk.styk.martin.bakalarka.execute.Main", "-analyze", "--in", utils.GetInputDir(), "--out", utils.GetOutputDir()).Output()

if metadata_error != nil {
Expand All @@ -62,12 +61,22 @@ func StartMetaDataCollection(apkPath string) models.MetaDataModel {
}

if metadata_success != nil {
fmt.Println("Metadata collection successful")
log.Info("Metadata collection successful")

file_path, file_name := filepath.Split(apkPath)
fmt.Println(file_path)
log.Info("File path: " + file_path)
log.Info("File name: " + file_name)

// Make file readable
os.Chmod(utils.GetOutputDir()+strings.Replace(file_name, ".apk", ".json", -1), 0777)
json_file_path := utils.GetOutputDir() + strings.Replace(file_name, ".apk", ".json", -1)
// Create a file with 777 permissions
_, err := os.Create(json_file_path)
if err != nil {
log.Error("Error creating file")
log.Error(err)
}
os.Chmod(json_file_path, 0777)

return startFileParser(utils.GetOutputDir() + strings.Replace(file_name, ".apk", ".json", -1))
}

Expand Down
2 changes: 1 addition & 1 deletion apk/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func StartSecScan(apkPath string) []models.SecretModel {

//Decompile the resources of the APK file
res_decompile, res_error := exec.Command("java", "-jar", "tools/apktool.jar", "d", "-s", apkPath, "-o", utils.GetResDir()).Output()

utils.HandleError(res_error, "Error while decompiling the APK file", true)

if res_decompile != nil {
Expand All @@ -86,6 +85,7 @@ func readPatternFile(patternFilePath string) []byte {
}

func StartScan(apkPath string) []models.SecretModel {
log.Info("Starting secret scan on the APK file")
files := utils.ReadDir(utils.GetAppFS(), "patterns")

var wg sync.WaitGroup
Expand Down

0 comments on commit cbe4240

Please sign in to comment.