Replace base64 with string escaping
This commit is contained in:
parent
70766e7358
commit
aa02d8945d
|
@ -1,4 +1,3 @@
|
||||||
import base64
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
|
@ -117,7 +116,7 @@ class ControlClient(object):
|
||||||
if not WormConfiguration.current_server:
|
if not WormConfiguration.current_server:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
telemetry = {'monkey_guid': GUID, 'log': base64.b64encode(log)}
|
telemetry = {'monkey_guid': GUID, 'log': json.dumps(log)}
|
||||||
reply = requests.post("https://%s/api/log" % (WormConfiguration.current_server,),
|
reply = requests.post("https://%s/api/log" % (WormConfiguration.current_server,),
|
||||||
data=json.dumps(telemetry),
|
data=json.dumps(telemetry),
|
||||||
headers={'content-type': 'application/json'},
|
headers={'content-type': 'application/json'},
|
||||||
|
|
|
@ -89,15 +89,27 @@ class PreviewPaneComponent extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadLog(asset) {
|
unescapeLog(st) {
|
||||||
|
return st.substr(1, st.length - 2) // remove quotation marks on beginning and end of string.
|
||||||
|
.replace(/\\n/g, "\n")
|
||||||
|
.replace(/\\r/g, "\r")
|
||||||
|
.replace(/\\t/g, "\t")
|
||||||
|
.replace(/\\b/g, "\b")
|
||||||
|
.replace(/\\f/g, "\f")
|
||||||
|
.replace(/\\"/g, '\"')
|
||||||
|
.replace(/\\'/g, "\'")
|
||||||
|
.replace(/\\&/g, "\&");
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadLog(asset) {
|
||||||
fetch('/api/log?id=' + asset.id)
|
fetch('/api/log?id=' + asset.id)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(res => {
|
.then(res => {
|
||||||
let timestamp = res['timestamp'];
|
let timestamp = res['timestamp'];
|
||||||
timestamp = timestamp.substr(0, timestamp.indexOf('.'));
|
timestamp = timestamp.substr(0, timestamp.indexOf('.'));
|
||||||
let filename = res['monkey_label'].split(':').join('-') + ' - ' + timestamp + '.log';
|
let filename = res['monkey_label'].split(':').join('-') + ' - ' + timestamp + '.log';
|
||||||
download(atob(res['log']), filename, 'text/plain');
|
let logContent = this.unescapeLog(res['log']);
|
||||||
|
download(logContent, filename, 'text/plain');
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue