This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Adds in Jetpack Scan API with models#304
Merged
emilylaguna merged 36 commits intodevelopfrom Nov 20, 2020
Merged
Conversation
added 27 commits
November 11, 2020 16:41
leandroalonso
suggested changes
Nov 18, 2020
Contributor
leandroalonso
left a comment
There was a problem hiding this comment.
@emilylaguna a few suggestions to reduce boilerplate code. :)
Contributor
Author
|
@leandroalonso Good idea about reducing boilerplate. Can you take another look? |
leandroalonso
suggested changes
Nov 19, 2020
Contributor
leandroalonso
left a comment
There was a problem hiding this comment.
@emilylaguna a few more suggestions to remove some additional lines. :)
yaelirub
reviewed
Nov 19, 2020
Contributor
Author
|
@leandroalonso was able to switch to using the I also added the |
leandroalonso
approved these changes
Nov 20, 2020
55 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
🙇♀️ I apologize this PR got bigger than I originally intended. The threat models ended up being a lot more complex.
There isn't a related WPiOS PR yet, so the tests being green and a thorough code review will work 👍
This PR introduces the
JetpackScanServiceRemoteclass that contains the method for starting a scan and getting scan information (status, availability, threats, etc). Since the API only uses 1 endpoint for getting scan information (sites/SITE_ID/scan) I've added a few "helper" methods to reduce the amount of information returned by thegetScanForSitemethod:getScanAvailableForSitejust returns theisEnabledboolgetCurrentScanStatusForSitejust returns the current scan status if it existsgetThreatsForSitejust returns the threats arrayThreats
I had originally planned on creating sub threat objects like
JetpackThreatCore,JetpackThreatDatabaseand only including the relevant properties for that type, but I couldn't get that to work within the decodable structure. Looking for suggestions to make this a bit cleaner.The
JetpackScanThreatobject is A LOT to look at so I'll provide any relevant information I can think of:The API does not return the threat type so we have to figure that out ourselves. Luckily wp-calypso already had this logic.
The fixable property points to a "Fixer" object that defines how a threat will be fixed if it can be. This information will be used to generate a string later such as "Jetpack will update this plugin to version 1.3.3.7"
JetpackThreatContext:context: ""Testing Details
🟢 Tests should be good!