Hello, I need your help writing a Java function iusing hte nterpret scan results of a…
- User
Hello, I need your help writing a Java function iusing hte nterpret scan results of a virus total scan via version v3 of its API. By the end of the scan this is what the request looks like: { "data": { "type": "analysis", "id": "NDRkODg2MTJmZWE4YThmMzZkZTgyZTEyNzhhYmIwMmY6MTY4NzU5NDIyNQ==", "links": { "self": "https://www.virustotal.com/api/v3/analyses/NDRkODg2MTJmZWE4YThmMzZkZTgyZTEyNzhhYmIwMmY6MTY4NzU5NDIyNQ==" } } }
- Assistant
- User
Hello, I'm quiet sorry but I have forgotten to speciy some parameters:
- First, I'll like to use the com.fasterxml.jackson.databind.JsonNode;, com.fasterxml.jackson.databind.ObjectMapper and com.fasterxml.jackson.databind.node.ArrayNode libraries or any other jackson library.
- Any web request should be done through okhttp3
- Assistant
- User
I really like what you are proposing but I would like it to be all in one class. Here is what already exists, please only write the new methods that need to be created. package com.efrei.ejlmguard;
import java.io.IOException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import okhttp3.*;
- Assistant
- User
I love you! It works! Now lastly I need to create a function called getIfMalicious(). From the response for VirusTotal, here is what it needs to do:
- If more than 25% of antivirus say it is malicious the porgram will return true
- The antivirus program that do not support the format are not counted in those 25%.
- Assistant
I'm glad it works! Now, here's the
getIfMalicious()function that checks if more than 25% of the antivirus programs say it is malicious:java - User
Great but we're not quiet there, please rewrite considering you will get the full body of the response from fetchResultFromServer(). It will returned as a String. Moreover, I will add oner small thing if the result is a positive, set virusName (a string) to be the same virus name as the one used by the first antivirus that says it has detected the file as malicious.
- Assistant
Sure! Here's the updated function considering you take the full body of the response from as a . I've also added the logic to set to the first antivirus that detects the file as malicious.