wordpress-mobile / WordPress-Android

WordPress for Android
http://android.wordpress.org
GNU General Public License v2.0
2.98k stars 1.32k forks source link

Jetpack Section: Scan - Threat Details Diff Viewer #13991

Open ashiagr opened 3 years ago

ashiagr commented 3 years ago

Goal

Goal of this issue is to implement a diff viewer in the app to view file changes for a core file modification type threat (found in a site’s scan results).

Details

For a site with a core file modification type threat, API https://public-api.wordpress.com/wpcom/v2/sites/<site_id>/scan returns core file modifications as a diff string in a Unified Format.

Calypso implementation relies on jsdiff to parse the output (the patch) and produce the data structure used to display files, hunks (sections of change in the files), and the actual lines of change and context.

Sample Input

--- /tmp/wordpress/5.5.3-en_US/wordpress/wp-admin/index.php\t2020-11-01 00:12:27.097473760 +0000\n+++ /tmp/4955714993/core-file-21107UtNwEVre9TgV\t2021-02-07 08:41:40.387958956 +0000\n@@ -183,3 +183,4 @@\n
wp_print_community_events_templates();\n\nrequire_once ABSPATH .'wp-admin/admin-footer.php';\n+if ( true === false ) exit();\n\\ No newline at end of file\n

Sample Output

diff_viewer

Currently this output is shown as plain text in the app:

diff-view-app

Implement a diff viewer in the app for viewing this diff string in the API response.

ashiagr commented 3 years ago

This task is on hold (Internal ref: p1612790034158400-slack-C0180B5PRJ4).