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

Add VirusTotal Results to API #92

Open
wants to merge 11 commits into
base: staging
Choose a base branch
from

Conversation

knightzac19
Copy link

Here is the API for the virustotal resultset from the API. First time I've ever messed with GraphQL to this extent, so I'm sure there's a lot of missing pieces to this.

@knightzac19 knightzac19 marked this pull request as ready for review September 30, 2024 17:58
@knightzac19 knightzac19 changed the title feat: add virustotal results to api Add VirusTotal Results to API Sep 30, 2024
Copy link

codecov bot commented Sep 30, 2024

Codecov Report

Attention: Patch coverage is 1.75316% with 2802 lines in your changes missing coverage. Please review.

Project coverage is 19.58%. Comparing base (c31f8d4) to head (afe1bda).

Files with missing lines Patch % Lines
generated/generated.go 0.16% 600 Missing ⚠️
generated/ent/virustotalresult_create.go 0.00% 394 Missing ⚠️
generated/ent/mutation.go 1.51% 389 Missing and 2 partials ⚠️
generated/ent/virustotalresult_query.go 0.00% 350 Missing ⚠️
generated/ent/virustotalresult_update.go 0.00% 266 Missing ⚠️
generated/ent/virustotalresult/where.go 0.00% 168 Missing ⚠️
generated/ent/version_update.go 0.00% 109 Missing and 3 partials ⚠️
generated/ent/virustotalresult.go 0.00% 97 Missing ⚠️
generated/ent/client.go 4.08% 94 Missing ⚠️
validation/virustotal.go 0.00% 61 Missing ⚠️
... and 19 more
Additional details and impacted files
@@             Coverage Diff             @@
##           staging      #92      +/-   ##
===========================================
- Coverage    20.56%   19.58%   -0.98%     
===========================================
  Files          247      256       +9     
  Lines        58404    61115    +2711     
===========================================
- Hits         12011    11972      -39     
- Misses       43863    46629    +2766     
+ Partials      2530     2514      -16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

db/schema/version.go Outdated Show resolved Hide resolved

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this the same name it would be using anyway? Why override it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generator was making the table virus_total_results

db/schema/virustotal_result.go Outdated Show resolved Hide resolved
db/schema/virustotal_result.go Outdated Show resolved Hide resolved
gql/resolver.go Outdated Show resolved Hide resolved
db/schema/virustotal_result.go Outdated Show resolved Hide resolved
validation/virustotal.go Outdated Show resolved Hide resolved
validation/virustotal.go Outdated Show resolved Hide resolved
validation/virustotal.go Outdated Show resolved Hide resolved
validation/virustotal.go Outdated Show resolved Hide resolved
@@ -78,7 +78,7 @@ func ScanFiles(ctx context.Context, files []io.Reader, names []string) ([]ScanRe
_ = errs.Wait()
close(c)
}()
var results []ScanResult
results := make([]ScanResult, 0, 100)
Copy link
Member

@Vilsol Vilsol Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 100? Why even give a size?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saw this error in the linter,

validation/virustotal.go:81:2: Consider pre-allocating `results` (prealloc)
	var results []ScanResult
	^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that just initializing a 0-size should be enough, setting a cap will cause problems when someone tries to upload a mod with 101 scanable items

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linter is probably detecting that the channel will pass at most len(fileCount) items, and wants you to use that as the initial size, make([]ScanResult, len(fileCount))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this should probably be rewritten as a select with a loop, because:

  1. We are just ignoring if the errs returns an error
  2. We are not guaranteed that fileCount many items will be sent to c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants