Skip to content

Commit

Permalink
feat: add virustotal results to api
Browse files Browse the repository at this point in the history
  • Loading branch information
knightzac19 committed Sep 30, 2024
1 parent c31f8d4 commit 00a41ef
Show file tree
Hide file tree
Showing 38 changed files with 6,329 additions and 343 deletions.
1 change: 1 addition & 0 deletions db/schema/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@ func (Version) Edges() []ent.Edge {
edge.To("dependencies", Mod.Type).
Through("version_dependencies", VersionDependency.Type),
edge.To("targets", VersionTarget.Type),
edge.To("virustotalResults", VirustotalResult.Type),
}
}
48 changes: 48 additions & 0 deletions db/schema/virustotal_result.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package schema

import (
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)

// YourTableName holds the schema definition for the YourTableName entity.
type VirustotalResult struct {
ent.Schema
}

func (VirustotalResult) Mixin() []ent.Mixin {
return []ent.Mixin{
IDMixin{},
TimeMixin{},
}
}

func (VirustotalResult) Fields() []ent.Field {
return []ent.Field{
field.Bool("safe").Default(false),
field.String("url").
NotEmpty(),
field.String("hash").Unique().NotEmpty(),
field.String("file_name").NotEmpty(),
field.String("version_id").NotEmpty(),
}
}

func (VirustotalResult) Annotations() []schema.Annotation {
return []schema.Annotation{
entsql.Annotation{Table: "virustotal_results"},
}
}

func (VirustotalResult) Edges() []ent.Edge {
return []ent.Edge{
edge.From("version", Version.Type).
Ref("virustotalResults").
Field("version_id").
Unique().
Required(),
}
}
1 change: 1 addition & 0 deletions generated/conv/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions generated/conv/virustotal_result.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

185 changes: 179 additions & 6 deletions generated/ent/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions generated/ent/ent.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 00a41ef

Please sign in to comment.