Skip to content

Commit

Permalink
Changed category handling
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFireMike committed May 8, 2020
1 parent 301f051 commit f69a45b
Show file tree
Hide file tree
Showing 8 changed files with 344 additions and 18 deletions.
181 changes: 181 additions & 0 deletions config/categories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
categories: |
Anwendung;
Anwendung/Clients;
Anwendung/Clients/Browser;
Anwendung/Clients/Browser/Chrome;
Anwendung/Clients/Browser/Firefox;
Anwendung/Clients/Browser/Internet_Explorer;
Anwendung/Clients/Browser/Opera;
Anwendung/Clients/Browser/Safari;
Anwendung/Clients/Browser/Silverlight;
Anwendung/Clients/Instant_Messenger;
Anwendung/Clients/Instant_Messenger/AIM_ICQ;
Anwendung/Clients/Instant_Messenger/MSN_Messenger;
Anwendung/Clients/Instant_Messenger/Trillian;
Anwendung/Clients/Instant_Messenger/Yahoo_Messenger;
Anwendung/Clients/Mail_Groupware;
Anwendung/Clients/Mail_Groupware/Lotus_Notes_Client;
Anwendung/Clients/Mail_Groupware/MS_Outlook_Express;
Anwendung/Clients/Mail_Groupware/MS_WindowsLiveMail;
Anwendung/Clients/Mail_Groupware/MS_WindowsMail;
Anwendung/Clients/Mail_Groupware/MS_Outlook;
Anwendung/Clients/Mail_Groupware/Thunderbird;
Anwendung/Clients/Multimedia;
Anwendung/Clients/Multimedia/Adobe_Flash_Player;
Anwendung/Clients/Multimedia/MS_MediaPlayer;
Anwendung/Clients/Multimedia/Quicktime;
Anwendung/Clients/Multimedia/Real_Player;
Anwendung/Clients/Multimedia/VLC;
Anwendung/Clients/Multimedia/WinAmp;
Anwendung/Clients/Office;
Anwendung/Clients/Office/Acrobat_Distiller;
Anwendung/Clients/Office/Acrobat_Reader;
Anwendung/Clients/Office/Foxit;
Anwendung/Clients/Office/LibreOffice;
Anwendung/Clients/Office/MS_Access;
Anwendung/Clients/Office/MS_Excel;
Anwendung/Clients/Office/MS_Office;
Anwendung/Clients/Office/MS_Powerpoint;
Anwendung/Clients/Office/MS_Project;
Anwendung/Clients/Office/MS_Word;
Anwendung/Clients/Office/MS_Works;
Anwendung/Clients/Office/OpenOffice;
Anwendung/Clients/Office/StarOffice;
Anwendung/Clients/Sonstiges;
Anwendung/Clients/Sonstiges/Citrix;
Anwendung/Clients/Sonstiges/Sun_Java;
Anwendung/Clients/Sonstiges/OpenSSH;
Anwendung/Clients/Sonstiges/pcAnywhere;
Anwendung/Clients/Sonstiges/RealVNC;
Anwendung/Clients/Sonstiges/SecureCRT;
Anwendung/Oracle;
Anwendung/Oracle/BigDataGraph;
Anwendung/Oracle/DatabaseServer;
Anwendung/Oracle/E-BusinessSuite;
Anwendung/Oracle/EnterpriseManager;
Anwendung/Oracle/FusionMiddleware;
Anwendung/Oracle/HealthSciencesApplications;
Anwendung/Oracle/Hyperion;
Anwendung/Oracle/IndustryApplications;
Anwendung/Oracle/JavaSE;
Anwendung/Oracle/JDEdwards;
Anwendung/Oracle/OracleMySQL;
Anwendung/Oracle/PeopleSoft;
Anwendung/Oracle/SecureBackup;
Anwendung/Oracle/SiebelCRM;
Anwendung/Oracle/SupplyChain;
Anwendung/Oracle/Virtualization;
Anwendung/Security;
Anwendung/Security/Antivirus;
Anwendung/Security/Antivirus/Avast;
Anwendung/Security/Antivirus/AVG_Internet_Security;
Anwendung/Security/Antivirus/Avira_Premium_Security_Suite;
Anwendung/Security/Antivirus/ClamAV;
Anwendung/Security/Antivirus/Kaspersky_Internet_Suite;
Anwendung/Security/Antivirus/Norton_AntiVirus;
Anwendung/Security/Antivirus/Norton_Internet_Security;
Anwendung/Security/Antivirus/Outpost_Security_Suite_Pro;
Anwendung/Security/Antivirus/Sophos;
Anwendung/Security/Antivirus/Symantec_Antivirus_Corporate_Edition;
Anwendung/Security/Antivirus/Symantec_Client_Security;
Anwendung/Security/Antivirus/Symantec_Endpoint_Protection;
Anwendung/Security/Antivirus/Symantec_Enterprise_Security_Manager;
Anwendung/Security/Antivirus/Symantec_Mail_Security_for_SMTP;
Anwendung/Security/Antivirus/Symantec_Scan_Engine;
Anwendung/Security/Crypto;
Anwendung/Security/Crypto/PGP;
Anwendung/Security/Crypto/GnuTLS;
Anwendung/Security/Crypto/OpenPGP;
Anwendung/Security/Crypto/OpenSSL;
Anwendung/Security/Firewall;
Anwendung/Security/Firewall/PIX_FWSM;
Anwendung/Security/Firewall/Symantec_Enterprise_Firewall;
Anwendung/Security/Firewall/Zone_Alarm;
Anwendung/Security/IDS_Monitoring;
Anwendung/Security/IDS_Monitoring/snort;
Anwendung/Security/IDS_Monitoring/wireshark;
Anwendung/Security/Sonstiges;
Anwendung/Security/Sonstiges/Symantec_Discovery;
Anwendung/Security/Sonstiges/Symantec_Management_Platform;
Anwendung/Security/Sonstiges/Symantec_Reporting_Server;
Anwendung/Security/Sonstiges/Symantec_Security_Expressions_Audit_and_;
Anwendung/Security/Sonstiges/Symantec_Web_Security;
Anwendung/Security/VPN;
Anwendung/Security/VPN/SINA;
Anwendung/Server;
Anwendung/Server/Backup_Storage;
Anwendung/Server/Backup_Storage/Arcserve;
Anwendung/Server/Backup_Storage/Symantec_Storage_Foundation;
Anwendung/Server/Backup_Storage/Tivoli_Storage_Manager;
Anwendung/Server/Backup_Storage/Veritas;
Anwendung/Server/Cloud_Computing;
Anwendung/Server/Customer-Relationship-Management;
Anwendung/Server/Datenbanken;
Anwendung/Server/Datenbanken/DB2;
Anwendung/Server/Datenbanken/Informix;
Anwendung/Server/Datenbanken/MS_SQL;
Anwendung/Server/Datenbanken/MySQL;
Anwendung/Server/Datenbanken/Oracle;
Anwendung/Server/Datenbanken/PostgreSQL;
Anwendung/Server/Internet_Intranet_Infrastruktur;
Anwendung/Server/Internet_Intranet_Infrastruktur/BIND;
Anwendung/Server/Internet_Intranet_Infrastruktur/eDirectory;
Anwendung/Server/Internet_Intranet_Infrastruktur/ISC_DHCPD;
Anwendung/Server/Mail;
Anwendung/Server/Mail/GroupeWise;
Anwendung/Server/Mail/Lotus_Domino;
Anwendung/Server/Mail/Lotus_Notes_Server;
Anwendung/Server/Mail/Microsoft_Exchange;
Anwendung/Server/Sonstiges;
Anwendung/Server/Sonstiges/JBoss;
Anwendung/Server/Web_Content_Management;
Anwendung/Server/Web_Content_Management/Drupal;
Anwendung/Server/Web_Content_Management/JOOMLA;
Anwendung/Server/Web_Content_Management/TYPO3;
Anwendung/Server/Web_Content_Management/WordPress;
Anwendung/Server/Web_Proxy_Fileserver;
Anwendung/Server/Web_Proxy_Fileserver/Apache_Tomcat;
Anwendung/Server/Web_Proxy_Fileserver/Apache_Webserver;
Anwendung/Server/Web_Proxy_Fileserver/Internet_Information_Services;
Anwendung/Server/Web_Proxy_Fileserver/Sun_Java_System_Webserver;
Anwendung/Server/Web_Proxy_Fileserver/Lotus_Domino_Webserver;
Anwendung/Server/Web_Proxy_Fileserver/MS_Proxy_Server;
Anwendung/Server/Web_Proxy_Fileserver/Samba;
Anwendung/Server/Web_Proxy_Fileserver/Squid;
Anwendung/Virtualisierung_Emulation;
Anwendung/Virtualisierung_Emulation/VMWare;
Betriebssystem;
Betriebssystem/Linux_Unix;
Betriebssystem/Linux_Unix/AIX;
Betriebssystem/Linux_Unix/Android;
Betriebssystem/Linux_Unix/Debian;
Betriebssystem/Linux_Unix/Fedora;
Betriebssystem/Linux_Unix/FreeBSD;
Betriebssystem/Linux_Unix/HP-UX;
Betriebssystem/Linux_Unix/IOS;
Betriebssystem/Linux_Unix/IRIX;
Betriebssystem/Linux_Unix/JUNOS;
Betriebssystem/Linux_Unix/Mac_OS;
Betriebssystem/Linux_Unix/Mac_OS_Server;
Betriebssystem/Linux_Unix/Mac_OS_X;
Betriebssystem/Linux_Unix/NetBSD;
Betriebssystem/Linux_Unix/Netware;
Betriebssystem/Linux_Unix/OpenBSD;
Betriebssystem/Linux_Unix/RedHat;
Betriebssystem/Linux_Unix/Solaris;
Betriebssystem/Linux_Unix/SuSE;
Betriebssystem/Linux_Unix/Ubuntu;
Betriebssystem/Oracle;
Betriebssystem/Oracle/OracleSystems;
Betriebssystem/Windows;
Betriebssystem/Windows/Windows_10;
Betriebssystem/Windows/Windows_2000;
Betriebssystem/Windows/Windows_7;
Betriebssystem/Windows/Windows_8;
Betriebssystem/Windows/Windows_81;
Betriebssystem/Windows/Windows_Server;
Betriebssystem/Windows/Windows_Vista;
Betriebssystem/Windows/Windows_XP;
Hardware;
Spezifikationen;
Spezifikationen/Netzwerkprotokoll;
6 changes: 3 additions & 3 deletions config/filter_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ filter_categories: |
1, Anwendung/Virtualisierung_Emulation;
2, Anwendung/Virtualisierung_Emulation;
3, Anwendung/Virtualisierung_Emulation;
2, Anwendung/Anwendung/Virtualisierung_Emulation/VMWare;
3, Anwendung/Anwendung/Virtualisierung_Emulation/VMWare;
2, Anwendung/Virtualisierung_Emulation/VMWare;
3, Anwendung/Virtualisierung_Emulation/VMWare;
1, Betriebssystem;
2, Betriebssystem;
1, Betriebssystem/Linux_Unix;
Expand All @@ -80,5 +80,5 @@ filter_categories: |
3, Betriebssystem/Windows/Windows_Server;
1, Hardware;
2, Hardware;
3, Hardware
3, Hardware;
excluded_filter_categories: |
8 changes: 8 additions & 0 deletions cve-alert-fetcher/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,14 @@ func initConfig() {
AnErr("Error:", err).
Msg("No config found")
}

viper.SetConfigName("categories")
err = viper.MergeInConfig()
if err != nil {
log.Info().
AnErr("Error:", err).
Msg("No config found")
}
}

func parseAndSetLogLevel(loglevel string) error {
Expand Down
8 changes: 8 additions & 0 deletions cve-alert-fetcher/cve_alert_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ func init() {
Msg("Failed reading in config")
}

viper.SetConfigName("categories")
err = viper.MergeInConfig()
if err != nil {
log.Error().
AnErr("Error:", err).
Msg("Failed reading in config")
}

viper.Set("init-db", true)
viper.Set("no-dele", true)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
Expand Down
8 changes: 0 additions & 8 deletions cve-alert-restapi/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,6 @@ func initConfig() {
AnErr("Error:", err).
Msg("No config found")
}

viper.SetConfigName("filter_config")
err = viper.MergeInConfig()
if err != nil {
log.Info().
AnErr("Error:", err).
Msg("No config found")
}
}

func parseAndSetLogLevel(loglevel string) error {
Expand Down
10 changes: 9 additions & 1 deletion cve-alert-restapi/cve_alert_restapi_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ func init() {
Msg("Failed reading in config")
}

viper.SetConfigName("categories")
err = viper.MergeInConfig()
if err != nil {
log.Error().
AnErr("Error:", err).
Msg("Failed reading in config")
}

viper.Set("init-db", true)
viper.Set("no-dele", true)
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
Expand Down Expand Up @@ -402,7 +410,7 @@ func TestFilterCategoriesRequestAll(t *testing.T) {
func TestFilterCategoriesAdd(t *testing.T) {
client := resty.New()
url := "http://localhost:" + port + "/filtercategory/add"
resp, err := client.R().SetHeader("Content-Type", "application/json").SetBody("{\"filter_id\":\"3\",\"category\":\"Test\"}").Post(url)
resp, err := client.R().SetHeader("Content-Type", "application/json").SetBody("{\"filter_id\":\"3\",\"category\":\"Anwendung/Clients/Browser/Firefox\"}").Post(url)
if err != nil {
log.Error().
AnErr("Error", err).
Expand Down
6 changes: 3 additions & 3 deletions cve-alert-restapi/request-handler/requestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ func addFilterCategory(c echo.Context) error {
}
err := alertmanager.AddFilterCategory(db, filterCategory.FilterId, filterCategory.Category)
if err != nil {
return c.String(http.StatusNotFound, "Filter Category already in DB!\n")
return c.String(http.StatusBadRequest, "Filter Category already in DB!\n")
}
return c.String(http.StatusOK, "Added filter category!\n")
}
Expand Down Expand Up @@ -1023,7 +1023,7 @@ func deleteExcludedFilterCategory(c echo.Context) error {
func getAllCategories(c echo.Context) error {
var categoryList []alertmanager.Category
sb := sqlbuilder.MySQL.NewSelectBuilder()
sb.Select("category").From("case_categories").GroupBy("category")
sb.Select("category").From("categories")
sql, args := sb.Build()
query, err := sqlbuilder.MySQL.Interpolate(sql, args)
if err != nil {
Expand All @@ -1049,7 +1049,7 @@ func getAllCategories(c echo.Context) error {
func getCategoriesOfOther(c echo.Context) error {
var categories []alertmanager.Category
sb := sqlbuilder.MySQL.NewSelectBuilder()
sb.Select("category").From("case_categories").Where("case_categories.category NOT IN (SELECT category FROM filter_categories)").GroupBy("category")
sb.Select("category").From("categories").Where("categories.category NOT IN (SELECT category FROM filter_categories)")
sql, args := sb.Build()
query, err := sqlbuilder.MySQL.Interpolate(sql, args)
if err != nil {
Expand Down
Loading

0 comments on commit f69a45b

Please sign in to comment.