Skip to content

Commit

Permalink
Fixed Issues with Results storage
Browse files Browse the repository at this point in the history
  • Loading branch information
amrudesh-cred committed Aug 8, 2024
1 parent 698a303 commit e2001a4
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 38 deletions.
9 changes: 5 additions & 4 deletions apk/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ limitations under the License.
import (
"encoding/json"
"fmt"
database "morf/db"
"morf/models"
"morf/utils"
util "morf/utils"
"net/http"
"path/filepath"

database "github.com/amrudesh1/morf/db"
"github.com/amrudesh1/morf/models"
"github.com/amrudesh1/morf/utils"
util "github.com/amrudesh1/morf/utils"

log "github.com/sirupsen/logrus"

"github.com/gin-gonic/gin"
Expand Down
13 changes: 7 additions & 6 deletions apk/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ limitations under the License.
import (
"encoding/json"
"io"
"morf/models"
"morf/utils"
"os"
"os/exec"
"path/filepath"
"strings"

"github.com/amrudesh1/morf/models"
"github.com/amrudesh1/morf/utils"

log "github.com/sirupsen/logrus"
alf "github.com/spf13/afero"
)
Expand All @@ -50,9 +51,9 @@ func StartMetaDataCollection(apkPath string) models.MetaDataModel {

// Move APK to input directory
apkPath = utils.CopyApktoInputDir(fs, apkPath)
log.Info("Starting metadata collection for " + apkPath)

log.Info("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,7 +63,7 @@ func StartMetaDataCollection(apkPath string) models.MetaDataModel {
}

if metadata_success != nil {
log.Debug("Metadata collection successful")
log.Debug("Metadata collection successful")
file_path, file_name := filepath.Split(apkPath)
log.Debug(file_path)

Expand Down
6 changes: 4 additions & 2 deletions apk/packageparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ limitations under the License.

import (
"fmt"
"morf/models"
util "morf/utils"
"regexp"
"strings"

"github.com/amrudesh1/morf/models"

util "github.com/amrudesh1/morf/utils"

"github.com/lib/pq"
)

Expand Down
4 changes: 2 additions & 2 deletions apk/resultparser.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package apk

import (
"morf/models"
"morf/utils"
"github.com/amrudesh1/morf/models"
"github.com/amrudesh1/morf/utils"

log "github.com/sirupsen/logrus"
"github.com/spf13/afero"
Expand Down
6 changes: 4 additions & 2 deletions apk/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ package apk

import (
"fmt"
"morf/models"
"morf/utils"
"os"
"os/exec"
"strconv"
"strings"
"sync"

"github.com/amrudesh1/morf/models"
"github.com/amrudesh1/morf/utils"

log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
)
Expand Down Expand Up @@ -109,6 +110,7 @@ func StartScan(apkPath string) []models.SecretModel {

for _, pattern := range secretPatterns.Patterns {
pat := pattern.Pattern.Regex
log.Info("Searching for pattern: " + pat)
result, err := exec.Command("rg", "-n", "-e", pat, "--multiline", utils.GetFilesDir()).Output()
if err != nil {
continue
Expand Down
5 changes: 3 additions & 2 deletions cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ limitations under the License.

import (
"fmt"
"morf/apk"
"morf/db"

"github.com/amrudesh1/morf/apk"
"github.com/amrudesh1/morf/db"

log "github.com/sirupsen/logrus"
cob "github.com/spf13/cobra"
Expand Down
5 changes: 3 additions & 2 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ limitations under the License.
*/package cmd

import (
"morf/db"
route "morf/router"
"net/http"
"time"

"github.com/amrudesh1/morf/db"
route "github.com/amrudesh1/morf/router"

gin "github.com/gin-gonic/gin"
cob "github.com/spf13/cobra"
vip "github.com/spf13/viper"
Expand Down
3 changes: 2 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ limitations under the License.

import (
"fmt"
"morf/models"
"os"

"github.com/amrudesh1/morf/models"

"gorm.io/driver/mysql"
"gorm.io/gorm"
)
Expand Down
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
module morf
module github.com/amrudesh1/morf

go 1.19

require (
github.com/gin-gonic/gin v1.9.0
google.golang.org/appengine v1.6.7
)
require github.com/gin-gonic/gin v1.9.0

require (
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -467,7 +465,6 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
Expand Down Expand Up @@ -532,7 +529,6 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package main

import "morf/cmd"
import "github.com/amrudesh1/morf/cmd"

func main() {
cmd.Execute()
Expand Down
9 changes: 5 additions & 4 deletions router/routers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ package router

import (
"fmt"
"morf/apk"
"morf/db"
"morf/models"
"morf/utils"
"net/http"

"github.com/amrudesh1/morf/apk"
"github.com/amrudesh1/morf/db"
"github.com/amrudesh1/morf/models"
"github.com/amrudesh1/morf/utils"

"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin/binding"
)
Expand Down
5 changes: 3 additions & 2 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import (
"encoding/json"
"fmt"
"io"
"morf/db"
"morf/models"
"net/http"
"os"
"os/exec"
"strconv"
"strings"
"syscall"

"github.com/amrudesh1/morf/db"
"github.com/amrudesh1/morf/models"

log "github.com/sirupsen/logrus"
alf "github.com/spf13/afero"
vip "github.com/spf13/viper"
Expand Down

0 comments on commit e2001a4

Please sign in to comment.