Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

ScanStore: Map ThreatModels based on types#1791

Merged
malinajirka merged 7 commits intodevelopfrom
issue/13326-threat-mapping-threat-types
Dec 7, 2020
Merged

ScanStore: Map ThreatModels based on types#1791
malinajirka merged 7 commits intodevelopfrom
issue/13326-threat-mapping-threat-types

Conversation

@ashiagr
Copy link
Copy Markdown
Contributor

@ashiagr ashiagr commented Dec 1, 2020

Issue: wordpress-mobile/WordPress-Android#13326

This PR converts ThreatModel to a sealed class and maps threat models based on different types.

Based on Calypso logic and threat types logic

  • File based threats (threat.context != null) will provide code context to be displayed.
  • Core modification threats (threat.diff != null) will contain a git diff string.
  • Database threats (threat.rows != null || 'Suspicious.Links' == threat.signature) will contain rows information.
  • VulnerableExtension threats (threat.extension != null) will contain extension information.

If none of these, threat is mapped as a GenericThreat.

To test

That unit tests in ThreatsMapperTest run fine for different types of threats.

Note

  • JSON data samples are taken from here with some of the fields replaced with ones sent in the API response (e.g. firstDetected is sent as first_detected).

@ashiagr ashiagr self-assigned this Dec 1, 2020
…ssue/13326-threat-mapping-threat-types

# Conflicts:
#	example/src/test/java/org/wordpress/android/fluxc/model/scan/threat/ThreatsMapperTest.kt
@ashiagr ashiagr changed the title [Scan Store] Map ThreatModels based on types ThreatStore: Map ThreatModels based on types Dec 1, 2020
Comment thread fluxc/src/main/java/org/wordpress/android/fluxc/model/scan/threat/ThreatMapper.kt Outdated
@ashiagr ashiagr requested review from malinajirka and zwarm December 2, 2020 12:03
@ashiagr ashiagr marked this pull request as ready for review December 2, 2020 12:04
@malinajirka malinajirka self-assigned this Dec 3, 2020
Base automatically changed from issue/13326-threat-mapping-context-deserialiser to develop December 4, 2020 15:42
Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

Great job @ashiagr! I've left a couple of comments - nitpicks and minor suggestions. Let me know what you think.

Comment thread fluxc/src/main/java/org/wordpress/android/fluxc/model/scan/threat/ThreatModel.kt Outdated
Comment thread fluxc/src/main/java/org/wordpress/android/fluxc/model/scan/threat/ThreatModel.kt Outdated
Comment thread fluxc/src/main/java/org/wordpress/android/fluxc/model/scan/threat/ThreatMapper.kt Outdated
@ashiagr ashiagr requested a review from malinajirka December 7, 2020 05:10
Copy link
Copy Markdown
Contributor

@malinajirka malinajirka left a comment

Choose a reason for hiding this comment

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

Thank you for all the changes ;)! LGTM

@malinajirka malinajirka merged commit 32d5abb into develop Dec 7, 2020
@malinajirka malinajirka deleted the issue/13326-threat-mapping-threat-types branch December 7, 2020 15:51
@ashiagr ashiagr changed the title ThreatStore: Map ThreatModels based on types ScanStore: Map ThreatModels based on types Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants