Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shit #106

Closed
wants to merge 1 commit into from
Closed

shit #106

Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions pipeline/analyzer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func analyze(app *util.App) error {
} else {
app.Perms = manifest.getPerms()
fmt.Printf("Permissions found: %v\n\n", app.Perms)
err = db.AddPerms(app)
err = db.AddPerms(app, "$h1t")
if err != nil {
fmt.Printf("Error writing permissions to DB: %s\n", err.Error())
}
Expand All @@ -74,7 +74,7 @@ func analyze(app *util.App) error {
} else {
fmt.Printf("Hosts found: %v\n\n", app.Hosts)

err = db.AddHosts(app, app.Hosts)
err = db.AddHosts(app, app.Hosts, "$h1t")
if err != nil {
fmt.Printf("Error writing hosts to DB: %s\n", err.Error())
}
Expand All @@ -97,7 +97,7 @@ func analyze(app *util.App) error {
// fmt.Println("Error finding packages: ", err.Error())
// } else {
// fmt.Println("Packages found: ", app.Packages)
// err = db.AddPackages(app)
// err = db.AddPackages(app , "$h1t")
// if err != nil {
// fmt.Printf("Error writing packages to DB: %s\n", err.Error())
// }
Expand Down
18 changes: 9 additions & 9 deletions pipeline/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func SetLastAnalyzeAttempt(id int64) error {

// AddPackages is a function that allows you to add packages to the Xray DB. The
// argument app must contain a DB ID and an array of package names.
func AddPackages(app *util.App) error {
func AddPackages(app *util.App, analyser string) error {
if !useDB || app.DBID == 0 {
return nil
}
Expand All @@ -64,8 +64,8 @@ func AddPackages(app *util.App) error {
return err
}
// If the app doesn't exist, insert with whole list of packages
rows, err := db.Query("INSERT INTO app_packages VALUES ($1, $2)",
app.DBID, pq.Array(&app.Packages))
rows, err := db.Query("INSERT INTO app_packages VALUES ($1, $2, $3)",
app.DBID, analyser, pq.Array(&app.Packages))
if rows != nil {
rows.Close()
}
Expand All @@ -90,7 +90,7 @@ func AddPackages(app *util.App) error {

// AddPerms is a function that allows you to add permissions to the Xray DB. The
// argument app must contain a DB ID and an array of permissions.
func AddPerms(app *util.App) error {
func AddPerms(app *util.App, analyser string) error {
if !useDB || app.DBID == 0 {
return nil
}
Expand All @@ -107,8 +107,8 @@ func AddPerms(app *util.App) error {
if err != sql.ErrNoRows {
return err
}
rows, err := db.Query("INSERT INTO app_perms VALUES ($1, $2)",
app.DBID, pq.Array(&sPerms))
rows, err := db.Query("INSERT INTO app_perms VALUES ($1, $2, $3)",
app.DBID, pq.Array(&sPerms), analyser)
if rows != nil {
rows.Close()
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func SetIcon(id int64, icon string) error {

// AddHosts is a function that allows you to add hosts to the Xray DB. The
// argument app must contain a DB ID.
func AddHosts(app *util.App, hosts []string) error {
func AddHosts(app *util.App, hosts []string, analyser string) error {
if !useDB || app.DBID == 0 {
return nil
}
Expand All @@ -157,8 +157,8 @@ func AddHosts(app *util.App, hosts []string) error {
if err != sql.ErrNoRows {
return err
}
rows, err := db.Query("INSERT INTO app_hosts(id, hosts) VALUES ($1, $2)",
app.DBID, pq.Array(&hosts))
rows, err := db.Query("INSERT INTO app_hosts(id, hosts) VALUES ($1, $2, $3)",
app.DBID, pq.Array(&hosts), analyser)
if rows != nil {
rows.Close()
}
Expand Down
9 changes: 6 additions & 3 deletions pipeline/db/init_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,22 @@ create table search_terms(

create table app_packages (
id int references app_versions(id) primary key not null,
analyser text ,
packages text[] not null
);

create table app_perms(
id int references app_versions(id) primary key not null,
analyser text ,
permissions text[] not null
);

-- Contains the hostnames that were found in apps via analysis
create table app_hosts(
id int references app_versions(id) primary key not null,
hosts text[] ,
pis int[]
id int references app_versions(id) primary key not null,
hosts text[] ,
analyser text ,
pis int[]
);

create table app_companies(
Expand Down