diff --git a/src/securityvalidationmodel.cpp b/src/securityvalidationmodel.cpp index a16af6db33eee7f1a63edc2047e49fcb31cc9517..2cbcfac00cdfefd5301886a487158f370748edfb 100644 --- a/src/securityvalidationmodel.cpp +++ b/src/securityvalidationmodel.cpp @@ -19,6 +19,8 @@ #include "account.h" #include "visitors/pixmapmanipulationvisitor.h" +#include <QtAlgorithms> + const QString SecurityValidationModel::messages[static_cast<const int>(SecurityFlaw::COUNT)] = { QObject::tr("Your communication negotation is secured, but not the media stream, please enable ZRTP or SDES"), QObject::tr("TLS is disabled, the negotiation wont be encrypted. Your communication will be vulnerable to " @@ -45,17 +47,17 @@ SecurityValidationModel::maximumSecurityLevel = {{ /* TLS_DISABLED */ SecurityLevel::WEAK , /* CERTIFICATE_EXPIRED */ SecurityLevel::MEDIUM , /* CERTIFICATE_SELF_SIGNED */ SecurityLevel::MEDIUM , - /* CA_CERTIFICATE_MISSING */ SecurityLevel::PARTIAL , - /* END_CERTIFICATE_MISSING */ SecurityLevel::PARTIAL , - /* PRIVATE_KEY_MISSING */ SecurityLevel::PARTIAL , + /* CA_CERTIFICATE_MISSING */ SecurityLevel::MEDIUM , + /* END_CERTIFICATE_MISSING */ SecurityLevel::MEDIUM , + /* PRIVATE_KEY_MISSING */ SecurityLevel::MEDIUM , /* CERTIFICATE_MISMATCH */ SecurityLevel::NONE , /* CERTIFICATE_STORAGE_PERMISSION */ SecurityLevel::ACCEPTABLE , /* CERTIFICATE_STORAGE_FOLDER */ SecurityLevel::ACCEPTABLE , /* CERTIFICATE_STORAGE_LOCATION */ SecurityLevel::ACCEPTABLE , /* OUTGOING_SERVER_MISMATCH */ SecurityLevel::ACCEPTABLE , - /* VERIFY_INCOMING_DISABLED */ SecurityLevel::PARTIAL , - /* VERIFY_ANSWER_DISABLED */ SecurityLevel::PARTIAL , - /* REQUIRE_CERTIFICATE_DISABLED */ SecurityLevel::PARTIAL , + /* VERIFY_INCOMING_DISABLED */ SecurityLevel::MEDIUM , + /* VERIFY_ANSWER_DISABLED */ SecurityLevel::MEDIUM , + /* REQUIRE_CERTIFICATE_DISABLED */ SecurityLevel::MEDIUM , /* MISSING_CERTIFICATE */ SecurityLevel::NONE , /* MISSING_AUTHORITY */ SecurityLevel::WEAK , }}; @@ -181,8 +183,14 @@ void SecurityValidationModel::update() m_lCurrentFlaws << Flaw(SecurityFlaw::CERTIFICATE_STORAGE_LOCATION,cert->type()); } } + qSort(m_lCurrentFlaws); emit layoutChanged(); } +QList<SecurityValidationModel::Flaw> SecurityValidationModel::currentFlaws() +{ + return m_lCurrentFlaws; +} + diff --git a/src/securityvalidationmodel.h b/src/securityvalidationmodel.h index 2ef6b85f9a68e7c78a302e8fc82a00796323441f..ad26369a0b39f95b1fbc054d707090fb3244877c 100644 --- a/src/securityvalidationmodel.h +++ b/src/securityvalidationmodel.h @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (C) 2013-2014 by Savoir-Faire Linux *** + * Copyright (C) 2013-2014 by Savoir-Faire Linux * * Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> * * * * This library is free software; you can redistribute it and/or * @@ -54,11 +54,10 @@ public: enum class SecurityLevel { NONE = 0, /* Security is not functional or severely defective */ WEAK = 1, /* There is some security, but way too many flaws */ - PARTIAL = 2, /* There is some security, but there is too many flaws */ - MEDIUM = 3, /* The security is probably good enough, but there is issues */ - ACCEPTABLE = 4, /* The security is most probably good enough, only minor issues */ - STRONG = 5, /* All the non-information items are correct */ - VERY_STRONG = 6, /* Everything, even the recommendations, are correct */ + MEDIUM = 2, /* The security is probably good enough, but there is issues */ + ACCEPTABLE = 3, /* The security is most probably good enough, only minor issues */ + STRONG = 4, /* All the non-information items are correct */ + COMPLETE = 5, /* Everything, even the recommendations, are correct */ }; ///The severity of a given flaw @@ -110,6 +109,12 @@ public: SecurityFlaw flaw; Severity severity; Certificate::Type certType; + bool operator < ( const Flaw &r ) const{ + return ( (int)severity > (int)r.severity ); + } + bool operator > ( const Flaw &r ) const{ + return ( (int)severity < (int)r.severity ); + } }; //Constructor @@ -123,6 +128,9 @@ public: Qt::ItemFlags flags ( const QModelIndex& index ) const; virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) ; + //Getter + QList<Flaw> currentFlaws(); + //Mutator void update();