triage tool: Add "Load from clipboard" functionality (#1599)

The user now can choose to "Load from file" or "Load from clipboard".
readme.txt has been adapted.
This commit is contained in:
Sebastian 2019-01-14 17:49:10 +01:00 committed by GitHub
parent aa40e374ac
commit 37f2aa0e2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 24 deletions

View File

@ -35,13 +35,26 @@ void MainWindow::loadFile()
const QString fileName = QFileDialog::getOpenFileName(this, tr("daca results file"), WORK_FOLDER, tr("Text files (*.txt);;All (*.*)"));
if (fileName.isEmpty())
return;
ui->results->clear();
QFile file(fileName);
file.open(QIODevice::ReadOnly | QIODevice::Text);
QTextStream textStream(&file);
load(textStream);
}
void MainWindow::loadFromClipboard()
{
ui->statusBar->clearMessage();
QString clipboardContent = QApplication::clipboard()->text();
QTextStream textStream(&clipboardContent);
load(textStream);
}
void MainWindow::load(QTextStream &textStream)
{
QString url;
QString errorMessage;
QStringList allErrors;
ui->results->clear();
while (true) {
QString line = textStream.readLine();
if (line.isNull())

View File

@ -3,6 +3,8 @@
#include <QMainWindow>
#include <QListWidgetItem>
#include <QString>
#include <QTextStream>
namespace Ui {
class MainWindow;
@ -19,11 +21,13 @@ public:
public slots:
void loadFile();
void loadFromClipboard();
void showResult(QListWidgetItem *item);
private:
Ui::MainWindow *ui;
void load(QTextStream &textStream);
bool runProcess(const QString &programName, const QStringList & arguments);
bool wget(const QString url);
bool unpackArchive(const QString archiveName);

View File

@ -22,7 +22,14 @@
<item>
<widget class="QPushButton" name="loadFile">
<property name="text">
<string>Load</string>
<string>Load from file</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="loadFromClipboard">
<property name="text">
<string>Load from clipboard</string>
</property>
</widget>
</item>
@ -89,7 +96,7 @@
<x>0</x>
<y>0</y>
<width>1057</width>
<height>25</height>
<height>21</height>
</rect>
</property>
</widget>
@ -113,22 +120,6 @@
</customwidgets>
<resources/>
<connections>
<connection>
<sender>loadFile</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>pasteResults()</slot>
<hints>
<hint type="sourcelabel">
<x>86</x>
<y>68</y>
</hint>
<hint type="destinationlabel">
<x>135</x>
<y>68</y>
</hint>
</hints>
</connection>
<connection>
<sender>results</sender>
<signal>itemDoubleClicked(QListWidgetItem*)</signal>
@ -161,9 +152,26 @@
</hint>
</hints>
</connection>
<connection>
<sender>loadFromClipboard</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>loadFromClipboard()</slot>
<hints>
<hint type="sourcelabel">
<x>142</x>
<y>55</y>
</hint>
<hint type="destinationlabel">
<x>528</x>
<y>268</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>loadFile()</slot>
<slot>showResult(QListWidgetItem*)</slot>
<slot>loadFromClipboard()</slot>
</slots>
</ui>

View File

@ -9,10 +9,12 @@ On Windows something like Cygwin is necessary and the directory containing the e
in the PATH environment variable (for example "C:\cygwin\bin").
Usage:
After triage has been started you have to load a daca results file via the "Load" button.
The file must contain the package URL line beginning with "ftp://" and the Cppcheck messages.
When the results file has been parsed successfully you can see a list of Cppcheck messages directly
beneath the "Load" button. Double-click any entry to let the tool show the source code and jump to
and mark the corresponding line. If the package is not found it is downloaded and extracted
After triage has been started you have to load daca results from a file via the "Load from file"
button or from the clipboard via the "Load from clipboard" button.
The file or clipboard text must contain the package URL line beginning with "ftp://" and the
Cppcheck messages.
When the results data has been parsed successfully you can see a list of Cppcheck messages directly
beneath the "Load ..." buttons. Double-click any entry to let the tool show the source code and jump
to and mark the corresponding line. If the package is not found it is downloaded and extracted
automatically. So after the first double-click it is normal that it takes some time until the
source code is shown.