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
Currently this output is shown as plain text in the app:
Implement a diff viewer in the app for viewing this diff string in the API response.
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 adiff
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
Sample Output
Currently this output is shown as plain text in the app:
Implement a diff viewer in the app for viewing this
diff
string in the API response.