From 6ff82e7b5619f049d633b6a01daebfc3d41b3a6f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 19 May 2017 01:13:53 +0100 Subject: [PATCH] Added support for VirusTotal. --- osrepodbmgr.Core/ChangeLog | 9 + osrepodbmgr.Core/Context.cs | 1 + osrepodbmgr.Core/Settings.cs | 24 ++ osrepodbmgr.Core/Workers/VirusTotal.cs | 341 ++++++++++++++++++ osrepodbmgr.Core/osrepodbmgr.Core.csproj | 6 + osrepodbmgr.Core/packages.config | 3 + osrepodbmgr.Eto.Desktop/ChangeLog | 5 + osrepodbmgr.Eto.Desktop/Program.cs | 2 + osrepodbmgr.Eto.XamMac2/ChangeLog | 5 + osrepodbmgr.Eto.XamMac2/Program.cs | 2 + osrepodbmgr.Eto/ChangeLog | 7 + osrepodbmgr.Eto/dlgSettings.xeto | 93 +++-- osrepodbmgr.Eto/dlgSettings.xeto.cs | 48 ++- osrepodbmgr.Eto/frmMain.xeto.cs | 101 +++++- osrepodbmgr/ChangeLog | 10 + osrepodbmgr/Program.cs | 2 + osrepodbmgr/dlgSettings.cs | 49 +++ osrepodbmgr/frmMain.cs | 118 +++++- osrepodbmgr/gtk-gui/gui.stetic | 130 ++++++- .../gtk-gui/osrepodbmgr.dlgSettings.cs | 174 +++++++-- osrepodbmgr/gtk-gui/osrepodbmgr.frmMain.cs | 2 +- 21 files changed, 1040 insertions(+), 92 deletions(-) create mode 100644 osrepodbmgr.Core/Workers/VirusTotal.cs diff --git a/osrepodbmgr.Core/ChangeLog b/osrepodbmgr.Core/ChangeLog index 4a95ea7..cc1b1de 100644 --- a/osrepodbmgr.Core/ChangeLog +++ b/osrepodbmgr.Core/ChangeLog @@ -1,3 +1,12 @@ +2017-05-19 Natalia Portillo + + * Context.cs: + * Settings.cs: + * packages.config: + * Workers/VirusTotal.cs: + * osrepodbmgr.Core.csproj: + Added support for VirusTotal. + 2017-05-18 Natalia Portillo * DBOps.cs: diff --git a/osrepodbmgr.Core/Context.cs b/osrepodbmgr.Core/Context.cs index 073a63c..e9a97c5 100644 --- a/osrepodbmgr.Core/Context.cs +++ b/osrepodbmgr.Core/Context.cs @@ -53,6 +53,7 @@ namespace osrepodbmgr.Core public static bool userExtracting; public static bool usableDotNetZip; public static string clamdVersion; + public static bool virusTotalEnabled; public delegate void UnarChangeStatusDelegate(); public static event UnarChangeStatusDelegate UnarChangeStatus; diff --git a/osrepodbmgr.Core/Settings.cs b/osrepodbmgr.Core/Settings.cs index 5edc8c8..4a3f46a 100644 --- a/osrepodbmgr.Core/Settings.cs +++ b/osrepodbmgr.Core/Settings.cs @@ -45,6 +45,8 @@ namespace osrepodbmgr.Core public string ClamdHost; public ushort ClamdPort; public bool ClamdIsLocal; + public bool UseVirusTotal; + public string VirusTotalKey; } public static class Settings @@ -152,6 +154,20 @@ namespace osrepodbmgr.Core else Current.ClamdIsLocal = false; + if(parsedPreferences.TryGetValue("UseVirusTotal", out obj)) + { + Current.ClamdIsLocal = ((NSNumber)obj).ToBool(); + } + else + Current.ClamdIsLocal = false; + + if(parsedPreferences.TryGetValue("VirusTotalKey", out obj)) + { + Current.ClamdHost = ((NSString)obj).ToString(); + } + else + Current.ClamdHost = null; + prefsFs.Close(); } else { @@ -195,6 +211,8 @@ namespace osrepodbmgr.Core Current.ClamdHost = (string)key.GetValue("ClamdHost"); Current.ClamdPort = (ushort)key.GetValue("ClamdPort"); Current.ClamdIsLocal = (bool)key.GetValue("ClamdIsLocal"); + Current.UseVirusTotal = (bool)key.GetValue("UseVirusTotal"); + Current.VirusTotalKey = (string)key.GetValue("VirusTotalKey"); } break; default: @@ -251,6 +269,8 @@ namespace osrepodbmgr.Core root.Add("ClamdHost", Current.ClamdHost); root.Add("ClamdPort", Current.ClamdPort); root.Add("ClamdIsLocal", Current.ClamdIsLocal); + root.Add("UseVirusTotal", Current.UseVirusTotal); + root.Add("VirusTotalKey", Current.VirusTotalKey); string preferencesPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Library", "Preferences"); string preferencesFilePath = Path.Combine(preferencesPath, "com.claunia.museum.osrepodbmgr.plist"); @@ -280,6 +300,8 @@ namespace osrepodbmgr.Core key.SetValue("ClamdHost", Current.ClamdHost); key.SetValue("ClamdPort", Current.ClamdPort); key.SetValue("ClamdIsLocal", Current.ClamdIsLocal); + key.SetValue("UseVirusTotal", Current.UseVirusTotal); + key.SetValue("VirusTotalKey", Current.VirusTotalKey); } break; default: @@ -320,6 +342,8 @@ namespace osrepodbmgr.Core Current.ClamdHost = null; Current.ClamdPort = 3310; Current.ClamdIsLocal = false; + Current.UseVirusTotal = false; + Current.VirusTotalKey = null; } } } diff --git a/osrepodbmgr.Core/Workers/VirusTotal.cs b/osrepodbmgr.Core/Workers/VirusTotal.cs new file mode 100644 index 0000000..4a78304 --- /dev/null +++ b/osrepodbmgr.Core/Workers/VirusTotal.cs @@ -0,0 +1,341 @@ +// +// Author: +// Natalia Portillo claunia@claunia.com +// +// Copyright (c) 2017, © Claunia.com +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in +// the documentation and/or other materials provided with the distribution. +// * Neither the name of the [ORGANIZATION] nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +using System; +using VirusTotalNET; +using VirusTotalNET.Results; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using VirusTotalNET.Objects; +using System.Collections.Generic; +using SharpCompress.Compressors.Deflate; +using SharpCompress.Compressors.BZip2; +using SharpCompress.Compressors.LZMA; +using System.Threading; + +namespace osrepodbmgr.Core +{ + public static partial class Workers + { + static VirusTotal vTotal; + + public static bool TestVirusTotal(string key) + { + VirusTotal vt; + FileReport report = null; + + try + { + Task.Run(async () => + { + vt = new VirusTotal(key); + report = await vt.GetFileReport("b82758fc5f737a58078d3c60e2798a70d895443a86aa39adf52dec70e98c2bed"); + }).Wait(); + } + catch(Exception ex) + { + if(Failed != null) + Failed(ex.InnerException.Message); + return false; + } + + return report != null && report.MD5 == "0bf60adb1435639a42b490e7e80d25c7"; + } + + public static bool InitVirusTotal(string key) + { + VirusTotal vt = null; + FileReport report = null; + + try + { + Task.Run(async () => + { + vt = new VirusTotal(key); + report = await vt.GetFileReport("b82758fc5f737a58078d3c60e2798a70d895443a86aa39adf52dec70e98c2bed"); + }).Wait(); + } + catch(Exception ex) + { + if(Failed != null) + Failed(ex.InnerException.Message); + return false; + } + + if(report != null && report.MD5 == "0bf60adb1435639a42b490e7e80d25c7") + { + vTotal = vt; + Context.virusTotalEnabled = true; + return true; + } + return false; + } + + public static void VirusTotalFileFromRepo(DBFile file) + { + try + { + if(!Context.virusTotalEnabled) + { + if(Failed != null) + Failed("VirusTotal is not usable"); + return; + } + + if(vTotal == null) + { + if(Failed != null) + Failed("VirusTotal is not initalized"); + } + + FileReport fResult = null; + + if(UpdateProgress != null) + UpdateProgress("Requesting existing report to VirusTotal", null, 0, 0); + + Task.Run(async () => + { + fResult = await vTotal.GetFileReport(file.Sha256); + }).Wait(); + + if(fResult.ResponseCode == VirusTotalNET.ResponseCodes.ReportResponseCode.Error) + { + if(Failed != null) + Failed(fResult.VerboseMsg); + return; + } + + if(fResult.ResponseCode == VirusTotalNET.ResponseCodes.ReportResponseCode.Present) + { + if(fResult.Positives > 0) + { + file.HasVirus = true; + if(fResult.Scans != null) + { + foreach(KeyValuePair engine in fResult.Scans) + { + if(engine.Value.Detected) + { + file.Virus = engine.Value.Result; + file.VirusTotalTime = engine.Value.Update; + dbCore.DBOps.UpdateFile(file); + + if(ScanFinished != null) + ScanFinished(file); + + return; + } + } + } + } + else + { + // If no scan has been done, mark as false. + // If a positive has already existed don't overwrite it. + file.HasVirus = false; + file.Virus = null; + file.VirusTotalTime = DateTime.UtcNow; + + dbCore.DBOps.UpdateFile(file); + + if(ScanFinished != null) + ScanFinished(file); + + return; + } + } + + string repoPath; + AlgoEnum algorithm; + + if(File.Exists(Path.Combine(Settings.Current.RepositoryPath, file.Sha256[0].ToString(), + file.Sha256[1].ToString(), file.Sha256[2].ToString(), + file.Sha256[3].ToString(), file.Sha256[4].ToString(), + file.Sha256 + ".gz"))) + { + repoPath = Path.Combine(Settings.Current.RepositoryPath, file.Sha256[0].ToString(), + file.Sha256[1].ToString(), file.Sha256[2].ToString(), + file.Sha256[3].ToString(), file.Sha256[4].ToString(), + file.Sha256 + ".gz"); + algorithm = AlgoEnum.GZip; + } + else if(File.Exists(Path.Combine(Settings.Current.RepositoryPath, file.Sha256[0].ToString(), + file.Sha256[1].ToString(), file.Sha256[2].ToString(), + file.Sha256[3].ToString(), file.Sha256[4].ToString(), + file.Sha256 + ".bz2"))) + { + repoPath = Path.Combine(Settings.Current.RepositoryPath, file.Sha256[0].ToString(), + file.Sha256[1].ToString(), file.Sha256[2].ToString(), + file.Sha256[3].ToString(), file.Sha256[4].ToString(), + file.Sha256 + ".bz2"); + algorithm = AlgoEnum.BZip2; + } + else if(File.Exists(Path.Combine(Settings.Current.RepositoryPath, file.Sha256[0].ToString(), + file.Sha256[1].ToString(), file.Sha256[2].ToString(), + file.Sha256[3].ToString(), file.Sha256[4].ToString(), + file.Sha256 + ".lzma"))) + { + repoPath = Path.Combine(Settings.Current.RepositoryPath, file.Sha256[0].ToString(), + file.Sha256[1].ToString(), file.Sha256[2].ToString(), + file.Sha256[3].ToString(), file.Sha256[4].ToString(), + file.Sha256 + ".lzma"); + algorithm = AlgoEnum.LZMA; + } + else + { + if(Failed != null) + Failed(string.Format("Cannot find file with hash {0} in the repository", file.Sha256)); + return; + } + + if(UpdateProgress != null) + UpdateProgress("Uncompressing file...", null, 0, 0); + + FileStream inFs = new FileStream(repoPath, FileMode.Open, FileAccess.Read); + Stream zStream = null; + + switch(algorithm) + { + case AlgoEnum.GZip: + zStream = new GZipStream(inFs, SharpCompress.Compressors.CompressionMode.Decompress); + break; + case AlgoEnum.BZip2: + zStream = new BZip2Stream(inFs, SharpCompress.Compressors.CompressionMode.Decompress); + break; + case AlgoEnum.LZMA: + byte[] properties = new byte[5]; + inFs.Read(properties, 0, 5); + inFs.Seek(8, SeekOrigin.Current); + zStream = new LzmaStream(properties, inFs); + break; + } + + ScanResult sResult = null; + + // Cannot use zStream directly, VirusTotal.NET requests the size *sigh* + string tmpFile = Path.Combine(Settings.Current.TemporaryFolder, Path.GetTempFileName()); + FileStream outFs = new FileStream(tmpFile, FileMode.Create, FileAccess.ReadWrite); + zStream.CopyTo(outFs); + zStream.Close(); + outFs.Seek(0, SeekOrigin.Begin); + + if(UpdateProgress != null) + UpdateProgress("Uploading file to VirusTotal...", null, 0, 0); + + Task.Run(async () => + { + sResult = await vTotal.ScanFile(outFs, file.Sha256); // Keep filename private, sorry! + }).Wait(); + outFs.Close(); + + File.Delete(tmpFile); + + if(sResult == null || sResult.ResponseCode == VirusTotalNET.ResponseCodes.ScanResponseCode.Error) + { + if(sResult == null) + { + if(Failed != null) + Failed("Cannot send file to VirusTotal"); + } + else + Failed(sResult.VerboseMsg); + + return; + } + + Task.Run(async () => + { + fResult = await vTotal.GetFileReport(file.Sha256); + }).Wait(); + + if(UpdateProgress != null) + UpdateProgress("Waiting for VirusTotal analysis...", null, 0, 0); + + while(fResult.ResponseCode == VirusTotalNET.ResponseCodes.ReportResponseCode.StillQueued) + { + // Wait 15 seconds so we fall in the 4 requests/minute + Thread.Sleep(15000); + + Task.Run(async () => + { + fResult = await vTotal.GetFileReport(file.Sha256); + }).Wait(); + } + + if(fResult.ResponseCode != VirusTotalNET.ResponseCodes.ReportResponseCode.Present) + { + if(Failed != null) + Failed(fResult.VerboseMsg); + return; + } + + if(fResult.Positives > 0) + { + file.HasVirus = true; + if(fResult.Scans != null) + { + foreach(KeyValuePair engine in fResult.Scans) + { + if(engine.Value.Detected) + { + file.Virus = engine.Value.Result; + file.VirusTotalTime = engine.Value.Update; + dbCore.DBOps.UpdateFile(file); + + if(ScanFinished != null) + ScanFinished(file); + + return; + } + } + } + } + else + { + // If no scan has been done, mark as false. + // If a positive has already existed don't overwrite it. + file.HasVirus = false; + file.Virus = null; + file.VirusTotalTime = DateTime.UtcNow; + + dbCore.DBOps.UpdateFile(file); + + if(ScanFinished != null) + ScanFinished(file); + + return; + } + } + catch(Exception ex) + { + if(Failed != null) + Failed(string.Format("Exception {0} when calling VirusTotal", ex.InnerException.Message)); + } + } + } +} diff --git a/osrepodbmgr.Core/osrepodbmgr.Core.csproj b/osrepodbmgr.Core/osrepodbmgr.Core.csproj index d4daa17..1e8d6c2 100644 --- a/osrepodbmgr.Core/osrepodbmgr.Core.csproj +++ b/osrepodbmgr.Core/osrepodbmgr.Core.csproj @@ -47,6 +47,11 @@ ..\packages\nClam.3.0.0\lib\net45\nClam.dll + + + + ..\packages\VirusTotal.NET.1.5.3\lib\net45\VirusTotal.NET.dll + @@ -70,6 +75,7 @@ + diff --git a/osrepodbmgr.Core/packages.config b/osrepodbmgr.Core/packages.config index 70132e7..99fecf4 100644 --- a/osrepodbmgr.Core/packages.config +++ b/osrepodbmgr.Core/packages.config @@ -6,4 +6,7 @@ + + + \ No newline at end of file diff --git a/osrepodbmgr.Eto.Desktop/ChangeLog b/osrepodbmgr.Eto.Desktop/ChangeLog index 9c872a4..f6b1a37 100644 --- a/osrepodbmgr.Eto.Desktop/ChangeLog +++ b/osrepodbmgr.Eto.Desktop/ChangeLog @@ -1,3 +1,8 @@ +2017-05-19 Natalia Portillo + + * Program.cs: + Added support for VirusTotal. + 2017-05-18 Natalia Portillo * Program.cs: diff --git a/osrepodbmgr.Eto.Desktop/Program.cs b/osrepodbmgr.Eto.Desktop/Program.cs index 33ddb58..c13f391 100644 --- a/osrepodbmgr.Eto.Desktop/Program.cs +++ b/osrepodbmgr.Eto.Desktop/Program.cs @@ -43,6 +43,8 @@ namespace osrepodbmgr.Eto.Desktop { if(Core.Settings.Current.UseClamd) Workers.InitClamd(); + if(Core.Settings.Current.UseVirusTotal) + Context.virusTotalEnabled = Workers.InitVirusTotal(Core.Settings.Current.VirusTotalKey); } Context.usableDotNetZip = !Platform.Detect.IsMac && !Platform.Detect.IsIos; diff --git a/osrepodbmgr.Eto.XamMac2/ChangeLog b/osrepodbmgr.Eto.XamMac2/ChangeLog index ac892d4..ef1df1d 100644 --- a/osrepodbmgr.Eto.XamMac2/ChangeLog +++ b/osrepodbmgr.Eto.XamMac2/ChangeLog @@ -1,3 +1,8 @@ +2017-05-19 Natalia Portillo + + * Program.cs: + Added support for VirusTotal. + 2017-05-18 Natalia Portillo * Program.cs: diff --git a/osrepodbmgr.Eto.XamMac2/Program.cs b/osrepodbmgr.Eto.XamMac2/Program.cs index 5017970..880924c 100644 --- a/osrepodbmgr.Eto.XamMac2/Program.cs +++ b/osrepodbmgr.Eto.XamMac2/Program.cs @@ -43,6 +43,8 @@ namespace osrepodbmgr.Eto.XamMac2 { if(Core.Settings.Current.UseClamd) Workers.InitClamd(); + if(Core.Settings.Current.UseVirusTotal) + Context.virusTotalEnabled = Workers.InitVirusTotal(Core.Settings.Current.VirusTotalKey); } Context.usableDotNetZip = false; new Application(Platforms.XamMac2).Run(new frmMain()); diff --git a/osrepodbmgr.Eto/ChangeLog b/osrepodbmgr.Eto/ChangeLog index 3b9bd5a..42a4345 100644 --- a/osrepodbmgr.Eto/ChangeLog +++ b/osrepodbmgr.Eto/ChangeLog @@ -1,3 +1,10 @@ +2017-05-19 Natalia Portillo + + * frmMain.xeto.cs: + * dlgSettings.xeto: + * dlgSettings.xeto.cs: + Added support for VirusTotal. + 2017-05-18 Natalia Portillo * frmMain.xeto: diff --git a/osrepodbmgr.Eto/dlgSettings.xeto b/osrepodbmgr.Eto/dlgSettings.xeto index 0feb2c9..e7c6aa9 100644 --- a/osrepodbmgr.Eto/dlgSettings.xeto +++ b/osrepodbmgr.Eto/dlgSettings.xeto @@ -1,5 +1,5 @@  - + @@ -69,38 +69,65 @@ Use antivirus? - - - - Use clamd? - - - - - - - - - - - - - - - - - - - - - - - - Clamd is local? - - - + + + + + Use clamd? + + + + + + + + + + + + + + + + + + + + + + + + Clamd is local? + + + + + + + + + Use VirusTotal? + + + + + + + + + + + + + + + + + + + diff --git a/osrepodbmgr.Eto/dlgSettings.xeto.cs b/osrepodbmgr.Eto/dlgSettings.xeto.cs index 3d54f98..c80b7e4 100644 --- a/osrepodbmgr.Eto/dlgSettings.xeto.cs +++ b/osrepodbmgr.Eto/dlgSettings.xeto.cs @@ -53,6 +53,11 @@ namespace osrepodbmgr.Eto Button btnClamdTest; Label lblClamdVersion; CheckBox chkClamdIsLocal; + GroupBox frmVirusTotal; + CheckBox chkVirusTotal; + TextBox txtVirusTotal; + Button btnVirusTotal; + Label lblVirusTotal; #pragma warning restore 0649 #endregion XAML UI elements @@ -83,6 +88,14 @@ namespace osrepodbmgr.Eto spClamdPort.Value = Core.Settings.Current.ClamdPort; chkClamdIsLocal.Checked = Core.Settings.Current.ClamdIsLocal; } + if(Core.Settings.Current.UseAntivirus && Core.Settings.Current.UseVirusTotal) + { + chkVirusTotal.Checked = true; + chkVirusTotal.Enabled = true; + txtVirusTotal.Enabled = true; + txtVirusTotal.Text = Core.Settings.Current.VirusTotalKey; + btnVirusTotal.Enabled = true; + } } protected void OnBtnCancelClicked(object sender, EventArgs e) @@ -105,7 +118,17 @@ namespace osrepodbmgr.Eto Core.Settings.Current.ClamdPort = 3310; Core.Settings.Current.ClamdIsLocal = false; } - Settings.SaveSettings(); + if(chkVirusTotal.Checked.Value && chkAntivirus.Checked.Value) + { + Core.Settings.Current.UseVirusTotal = true; + Core.Settings.Current.VirusTotalKey = txtVirusTotal.Text; + Core.Workers.InitVirusTotal(Core.Settings.Current.VirusTotalKey); + } + else + { + Core.Settings.Current.UseVirusTotal = false; + Core.Settings.Current.VirusTotalKey = null; + } Settings.SaveSettings(); Workers.CloseDB(); Workers.InitDB(); Context.clamdVersion = null; @@ -250,6 +273,7 @@ namespace osrepodbmgr.Eto protected void OnChkAntivirusToggled(object sender, EventArgs e) { frmClamd.Visible = chkAntivirus.Checked.Value; + frmVirusTotal.Visible = chkAntivirus.Checked.Value; } protected void OnChkClamdToggled(object sender, EventArgs e) @@ -294,5 +318,27 @@ namespace osrepodbmgr.Eto Context.clamdVersion = oldVersion; lblClamdVersion.Visible = true; } + + protected void OnChkVirusTotalToggled(object sender, EventArgs e) + { + txtVirusTotal.Enabled = chkVirusTotal.Checked.Value; + btnVirusTotal.Enabled = chkVirusTotal.Checked.Value; + lblVirusTotal.Visible = false; + } + + protected void OnBtnVirusTotalClicked(object sender, EventArgs e) + { + Workers.Failed += VirusTotalTestFailed; + if(Workers.TestVirusTotal(txtVirusTotal.Text)) + { + lblVirusTotal.Visible = true; + lblVirusTotal.Text = "Working!"; + } + } + + void VirusTotalTestFailed(string text) + { + MessageBox.Show(text, MessageBoxType.Error); + } } } diff --git a/osrepodbmgr.Eto/frmMain.xeto.cs b/osrepodbmgr.Eto/frmMain.xeto.cs index ae66b1c..1e54c0e 100644 --- a/osrepodbmgr.Eto/frmMain.xeto.cs +++ b/osrepodbmgr.Eto/frmMain.xeto.cs @@ -654,13 +654,13 @@ namespace osrepodbmgr.Eto btnToggleCrack.Enabled = false; btnScanWithClamd.Enabled = false; btnCheckInVirusTotal.Enabled = false; - prgProgress.Visible = true; - lblProgress.Visible = true; + prgProgressFiles1.Visible = true; + lblProgressFiles1.Visible = true; Workers.Failed += ClamdFailed; Workers.ScanFinished += ClamdFinished; - lblProgress.Text = "Scanning file with clamd."; - prgProgress.Indeterminate = true; + lblProgressFiles1.Text = "Scanning file with clamd."; + prgProgressFiles1.Indeterminate = true; thdScanFile = new Thread(() => Workers.ClamScanFileFromRepo(file)); thdScanFile.Start(); @@ -675,11 +675,11 @@ namespace osrepodbmgr.Eto btnToggleCrack.Enabled = true; btnScanWithClamd.Enabled = true; btnCheckInVirusTotal.Enabled = true; - prgProgress.Visible = false; - lblProgress.Visible = false; + prgProgressFiles1.Visible = false; + lblProgressFiles1.Visible = false; Workers.Failed -= ClamdFailed; Workers.ScanFinished -= ClamdFinished; - lblProgress.Text = ""; + lblProgressFiles1.Text = ""; if(thdScanFile != null) { thdScanFile.Abort(); @@ -698,9 +698,9 @@ namespace osrepodbmgr.Eto btnCheckInVirusTotal.Enabled = true; Workers.Failed -= ClamdFailed; Workers.ScanFinished -= ClamdFinished; - lblProgress.Text = ""; - prgProgress.Visible = false; - lblProgress.Visible = false; + lblProgressFiles1.Text = ""; + prgProgressFiles1.Visible = false; + lblProgressFiles1.Visible = false; if(thdScanFile != null) thdScanFile = null; @@ -711,13 +711,88 @@ namespace osrepodbmgr.Eto protected void OnBtnCheckInVirusTotalClicked(object sender, EventArgs e) { + if(treeFiles.SelectedItem != null) + { + DBFile file = Workers.GetDBFile(((DBFile)treeFiles.SelectedItem).Sha256); + outIter = (osrepodbmgr.Core.DBFile)treeFiles.SelectedItem; + + if(file == null) + { + MessageBox.Show("Cannot get file from database", MessageBoxType.Error); + return; + } + + treeFiles.Enabled = false; + btnToggleCrack.Enabled = false; + btnScanWithClamd.Enabled = false; + btnCheckInVirusTotal.Enabled = false; + prgProgressFiles1.Visible = true; + lblProgressFiles1.Visible = true; + Workers.Failed += VirusTotalFailed; + Workers.ScanFinished += VirusTotalFinished; + Workers.UpdateProgress += UpdateVirusProgress; + + lblProgressFiles1.Text = "Scanning file with VirusTotal."; + prgProgressFiles1.Indeterminate = true; + + thdScanFile = new Thread(() => Workers.VirusTotalFileFromRepo(file)); + thdScanFile.Start(); + } + } + + void VirusTotalFailed(string text) + { + Application.Instance.Invoke(delegate + { + MessageBox.Show(text, MessageBoxType.Error); + treeFiles.Enabled = true; + btnToggleCrack.Enabled = true; + btnScanWithClamd.Enabled = true; + btnCheckInVirusTotal.Enabled = true; + prgProgressFiles1.Visible = false; + Workers.Failed -= VirusTotalFailed; + Workers.ScanFinished -= VirusTotalFinished; + Workers.UpdateProgress -= UpdateVirusProgress; + lblProgressFiles1.Text = ""; + if(thdScanFile != null) + { + thdScanFile.Abort(); + thdScanFile = null; + } + }); + } + + void VirusTotalFinished(DBFile file) + { + Application.Instance.Invoke(delegate + { + treeFiles.Enabled = true; + btnToggleCrack.Enabled = true; + btnScanWithClamd.Enabled = true; + btnCheckInVirusTotal.Enabled = true; + Workers.Failed -= VirusTotalFailed; + Workers.ScanFinished -= VirusTotalFinished; + Workers.UpdateProgress -= UpdateVirusProgress; + lblProgressFiles1.Text = ""; + prgProgressFiles1.Visible = false; + if(thdScanFile != null) + thdScanFile = null; + + lstFiles.Remove(outIter); + AddFile(file); + }); + } + + public void UpdateVirusProgress(string text, string inner, long current, long maximum) + { + Application.Instance.Invoke(delegate + { + lblProgressFiles1.Text = text; + }); } protected void OnBtnPopulateFilesClicked(object sender, EventArgs e) { - // TODO: Implement - btnCheckInVirusTotal.Enabled = false; - tabOSes.Enabled = false; btnStopFiles.Visible = true; btnPopulateFiles.Visible = false; diff --git a/osrepodbmgr/ChangeLog b/osrepodbmgr/ChangeLog index 817f2c6..765407b 100644 --- a/osrepodbmgr/ChangeLog +++ b/osrepodbmgr/ChangeLog @@ -1,3 +1,13 @@ +2017-05-19 Natalia Portillo + + * Program.cs: + * frmMain.cs: + * dlgSettings.cs: + * gtk-gui/gui.stetic: + * gtk-gui/osrepodbmgr.frmMain.cs: + * gtk-gui/osrepodbmgr.dlgSettings.cs: + Added support for VirusTotal. + 2017-05-18 Natalia Portillo * frmMain.cs: diff --git a/osrepodbmgr/Program.cs b/osrepodbmgr/Program.cs index fb521bd..fe80a5c 100644 --- a/osrepodbmgr/Program.cs +++ b/osrepodbmgr/Program.cs @@ -41,6 +41,8 @@ namespace osrepodbmgr { if(Core.Settings.Current.UseClamd) Workers.InitClamd(); + if(Core.Settings.Current.UseVirusTotal) + Context.virusTotalEnabled = Workers.InitVirusTotal(Core.Settings.Current.VirusTotalKey); } Application.Init(); frmMain win = new frmMain(); diff --git a/osrepodbmgr/dlgSettings.cs b/osrepodbmgr/dlgSettings.cs index 7e288b8..361c5d1 100644 --- a/osrepodbmgr/dlgSettings.cs +++ b/osrepodbmgr/dlgSettings.cs @@ -81,6 +81,19 @@ namespace osrepodbmgr txtClamdHost.Text = Core.Settings.Current.ClamdHost; spClamdPort.Value = Core.Settings.Current.ClamdPort; chkClamdIsLocal.Active = Core.Settings.Current.ClamdIsLocal; + chkClamd.Sensitive = true; + chkClamdIsLocal.Sensitive = true; + txtClamdHost.Sensitive = true; + spClamdPort.Sensitive = true; + btnClamdTest.Sensitive = true; + } + if(Core.Settings.Current.UseAntivirus && Core.Settings.Current.UseVirusTotal) + { + chkVirusTotal.Active = true; + chkVirusTotal.Sensitive = true; + txtVirusTotal.Sensitive = true; + txtVirusTotal.Text = Core.Settings.Current.VirusTotalKey; + btnVirusTotal.Sensitive = true; } } @@ -121,6 +134,17 @@ namespace osrepodbmgr Core.Settings.Current.ClamdPort = 3310; Core.Settings.Current.ClamdIsLocal = false; } + if(chkVirusTotal.Active && chkAntivirus.Active) + { + Core.Settings.Current.UseVirusTotal = true; + Core.Settings.Current.VirusTotalKey = txtVirusTotal.Text; + Core.Workers.InitVirusTotal(Core.Settings.Current.VirusTotalKey); + } + else + { + Core.Settings.Current.UseVirusTotal = false; + Core.Settings.Current.VirusTotalKey = null; + } Core.Settings.SaveSettings(); Core.Workers.CloseDB(); Core.Workers.InitDB(); @@ -286,6 +310,7 @@ namespace osrepodbmgr protected void OnChkAntivirusToggled(object sender, EventArgs e) { frmClamd.Visible = chkAntivirus.Active; + frmVirusTotal.Visible = chkAntivirus.Active; } protected void OnChkClamdToggled(object sender, EventArgs e) @@ -334,5 +359,29 @@ namespace osrepodbmgr Context.clamdVersion = oldVersion; lblClamdVersion.Visible = true; } + + protected void OnChkVirusTotalToggled(object sender, EventArgs e) + { + txtVirusTotal.Sensitive = chkVirusTotal.Active; + btnVirusTotal.Sensitive = chkVirusTotal.Active; + lblVirusTotal.Visible = false; + } + + protected void OnBtnVirusTotalClicked(object sender, EventArgs e) + { + Workers.Failed += VirusTotalTestFailed; + if(Workers.TestVirusTotal(txtVirusTotal.Text)) + { + lblVirusTotal.Visible = true; + lblVirusTotal.Text = "Working!"; + } + } + + void VirusTotalTestFailed(string text) + { + MessageDialog dlgMsg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, text); + dlgMsg.Run(); + dlgMsg.Destroy(); + } } } diff --git a/osrepodbmgr/frmMain.cs b/osrepodbmgr/frmMain.cs index 3566028..ead5585 100644 --- a/osrepodbmgr/frmMain.cs +++ b/osrepodbmgr/frmMain.cs @@ -671,18 +671,18 @@ namespace osrepodbmgr btnToggleCrack.Sensitive = false; btnScanWithClamd.Sensitive = false; btnCheckInVirusTotal.Sensitive = false; - prgProgress.Visible = true; + prgProgressFiles1.Visible = true; Workers.Failed += ClamdFailed; Workers.ScanFinished += ClamdFinished; - prgProgress.Text = "Scanning file with clamd."; + prgProgressFiles1.Text = "Scanning file with clamd."; thdPulseProgress = new Thread(() => { while(true) { Application.Invoke(delegate { - prgProgress.Pulse(); + prgProgressFiles1.Pulse(); }); Thread.Sleep(66); } @@ -701,10 +701,10 @@ namespace osrepodbmgr btnToggleCrack.Sensitive = true; btnScanWithClamd.Sensitive = true; btnCheckInVirusTotal.Sensitive = true; - prgProgress.Visible = false; + prgProgressFiles1.Visible = false; Workers.Failed -= ClamdFailed; Workers.ScanFinished -= ClamdFinished; - prgProgress.Text = ""; + prgProgressFiles1.Text = ""; if(thdPulseProgress != null) { thdPulseProgress.Abort(); @@ -728,8 +728,8 @@ namespace osrepodbmgr btnCheckInVirusTotal.Sensitive = true; Workers.Failed -= ClamdFailed; Workers.ScanFinished -= ClamdFinished; - prgProgress.Text = ""; - prgProgress.Visible = false; + prgProgressFiles1.Text = ""; + prgProgressFiles1.Visible = false; if(thdPulseProgress != null) { thdPulseProgress.Abort(); @@ -745,13 +745,111 @@ namespace osrepodbmgr protected void OnBtnCheckInVirusTotalClicked(object sender, EventArgs e) { + if(treeFiles.Selection.GetSelected(out outIter)) + { + DBFile file = Workers.GetDBFile((string)fileView.GetValue(outIter, 0)); + + if(file == null) + { + MessageDialog dlgMsg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, + "Cannot get file from database"); + dlgMsg.Run(); + dlgMsg.Destroy(); + return; + } + + treeFiles.Sensitive = false; + btnToggleCrack.Sensitive = false; + btnScanWithClamd.Sensitive = false; + btnCheckInVirusTotal.Sensitive = false; + prgProgressFiles1.Visible = true; + Workers.Failed += VirusTotalFailed; + Workers.ScanFinished += VirusTotalFinished; + Workers.UpdateProgress += UpdateVirusProgress; + + prgProgressFiles1.Text = "Scanning file with VirusTotal."; + thdPulseProgress = new Thread(() => + { + while(true) + { + Application.Invoke(delegate + { + prgProgressFiles1.Pulse(); + }); + Thread.Sleep(66); + } + }); + + thdScanFile = new Thread(() => Workers.VirusTotalFileFromRepo(file)); + thdScanFile.Start(); + } + } + + void VirusTotalFailed(string text) + { + Application.Invoke(delegate + { + MessageDialog dlgMsg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, text); + dlgMsg.Run(); + dlgMsg.Destroy(); + treeFiles.Sensitive = true; + btnToggleCrack.Sensitive = true; + btnScanWithClamd.Sensitive = true; + btnCheckInVirusTotal.Sensitive = true; + prgProgressFiles1.Visible = false; + Workers.Failed -= VirusTotalFailed; + Workers.ScanFinished -= VirusTotalFinished; + Workers.UpdateProgress -= UpdateVirusProgress; + prgProgressFiles1.Text = ""; + if(thdPulseProgress != null) + { + thdPulseProgress.Abort(); + thdPulseProgress = null; + } + if(thdScanFile != null) + { + thdScanFile.Abort(); + thdScanFile = null; + } + }); + } + + void VirusTotalFinished(DBFile file) + { + Application.Invoke(delegate + { + treeFiles.Sensitive = true; + btnToggleCrack.Sensitive = true; + btnScanWithClamd.Sensitive = true; + btnCheckInVirusTotal.Sensitive = true; + Workers.Failed -= VirusTotalFailed; + Workers.ScanFinished -= VirusTotalFinished; + Workers.UpdateProgress -= UpdateVirusProgress; + prgProgressFiles1.Text = ""; + prgProgressFiles1.Visible = false; + if(thdPulseProgress != null) + { + thdPulseProgress.Abort(); + thdPulseProgress = null; + } + if(thdScanFile != null) + thdScanFile = null; + + fileView.Remove(ref outIter); + AddFile(file); + }); + } + + public void UpdateVirusProgress(string text, string inner, long current, long maximum) + { + Application.Invoke(delegate + { + prgProgressFiles1.Text = text; + }); } protected void OnBtnPopulateFilesClicked(object sender, EventArgs e) { - // TODO: Implement - btnCheckInVirusTotal.Sensitive = false; - notebook1.GetNthPage(0).Sensitive = false; btnStopFiles.Visible = true; btnPopulateFiles.Visible = false; diff --git a/osrepodbmgr/gtk-gui/gui.stetic b/osrepodbmgr/gtk-gui/gui.stetic index 4e7a699..a7c508c 100644 --- a/osrepodbmgr/gtk-gui/gui.stetic +++ b/osrepodbmgr/gtk-gui/gui.stetic @@ -967,7 +967,7 @@ QNX/QNX/20090229/source.zip - + Settings CenterOnParent @@ -1326,6 +1326,7 @@ QNX/QNX/20090229/source.zip + False True True @@ -1350,6 +1351,7 @@ QNX/QNX/20090229/source.zip + False True 1 65535 @@ -1369,6 +1371,7 @@ QNX/QNX/20090229/source.zip + False True TextOnly Test @@ -1405,6 +1408,7 @@ QNX/QNX/20090229/source.zip + False True Clamd is local? True @@ -1423,7 +1427,7 @@ QNX/QNX/20090229/source.zip - + <b>clamd</b> True @@ -1440,6 +1444,126 @@ QNX/QNX/20090229/source.zip False + + + + None + + + + 0 + 0 + 12 + + + + 6 + + + + True + Use VirusTotal? + True + True + True + + + + 0 + True + False + False + + + + + + 6 + + + + API Key + + + 0 + True + False + False + + + + + + False + True + True + + + + 1 + True + + + + + + False + True + TextOnly + Test + True + + + + 2 + True + False + False + + + + + 1 + True + False + False + + + + + + False + label5 + + + 2 + True + False + False + + + + + + + + + + <b>VirusTotal</b> + True + + + label_item + + + + + 2 + True + False + False + + 1 @@ -12591,7 +12715,7 @@ QNX/QNX/20090229/source.zip True - 1 + 0 diff --git a/osrepodbmgr/gtk-gui/osrepodbmgr.dlgSettings.cs b/osrepodbmgr/gtk-gui/osrepodbmgr.dlgSettings.cs index a22a14e..d2cc31e 100644 --- a/osrepodbmgr/gtk-gui/osrepodbmgr.dlgSettings.cs +++ b/osrepodbmgr/gtk-gui/osrepodbmgr.dlgSettings.cs @@ -76,7 +76,27 @@ namespace osrepodbmgr private global::Gtk.CheckButton chkClamdIsLocal; - private global::Gtk.Label GtkLabel7; + private global::Gtk.Label GtkLabel8; + + private global::Gtk.Frame frame2; + + private global::Gtk.Alignment GtkAlignment7; + + private global::Gtk.VBox vbox7; + + private global::Gtk.CheckButton chkVirusTotal; + + private global::Gtk.HBox hbox4; + + private global::Gtk.Label label6; + + private global::Gtk.Entry txtVirusTotal; + + private global::Gtk.Button btnVirusTotal; + + private global::Gtk.Label lblVirusTotal; + + private global::Gtk.Label GtkLabel12; private global::Gtk.HBox hbox18; @@ -364,6 +384,7 @@ namespace osrepodbmgr w29.Fill = false; // Container child hbox3.Gtk.Box+BoxChild this.txtClamdHost = new global::Gtk.Entry(); + this.txtClamdHost.Sensitive = false; this.txtClamdHost.CanFocus = true; this.txtClamdHost.Name = "txtClamdHost"; this.txtClamdHost.IsEditable = true; @@ -382,6 +403,7 @@ namespace osrepodbmgr w31.Fill = false; // Container child hbox3.Gtk.Box+BoxChild this.spClamdPort = new global::Gtk.SpinButton(1, 65535, 1); + this.spClamdPort.Sensitive = false; this.spClamdPort.CanFocus = true; this.spClamdPort.Name = "spClamdPort"; this.spClamdPort.Adjustment.PageIncrement = 10; @@ -395,6 +417,7 @@ namespace osrepodbmgr w32.Fill = false; // Container child hbox3.Gtk.Box+BoxChild this.btnClamdTest = new global::Gtk.Button(); + this.btnClamdTest.Sensitive = false; this.btnClamdTest.CanFocus = true; this.btnClamdTest.Name = "btnClamdTest"; this.btnClamdTest.UseUnderline = true; @@ -420,6 +443,7 @@ namespace osrepodbmgr w35.Fill = false; // Container child vbox6.Gtk.Box+BoxChild this.chkClamdIsLocal = new global::Gtk.CheckButton(); + this.chkClamdIsLocal.Sensitive = false; this.chkClamdIsLocal.CanFocus = true; this.chkClamdIsLocal.Name = "chkClamdIsLocal"; this.chkClamdIsLocal.Label = global::Mono.Unix.Catalog.GetString("Clamd is local?"); @@ -432,26 +456,111 @@ namespace osrepodbmgr w36.Fill = false; this.GtkAlignment6.Add(this.vbox6); this.frmClamd.Add(this.GtkAlignment6); - this.GtkLabel7 = new global::Gtk.Label(); - this.GtkLabel7.Name = "GtkLabel7"; - this.GtkLabel7.LabelProp = global::Mono.Unix.Catalog.GetString("clamd"); - this.GtkLabel7.UseMarkup = true; - this.frmClamd.LabelWidget = this.GtkLabel7; + this.GtkLabel8 = new global::Gtk.Label(); + this.GtkLabel8.Name = "GtkLabel8"; + this.GtkLabel8.LabelProp = global::Mono.Unix.Catalog.GetString("clamd"); + this.GtkLabel8.UseMarkup = true; + this.frmClamd.LabelWidget = this.GtkLabel8; this.vbox4.Add(this.frmClamd); global::Gtk.Box.BoxChild w39 = ((global::Gtk.Box.BoxChild)(this.vbox4[this.frmClamd])); w39.Position = 1; w39.Expand = false; w39.Fill = false; - this.hbox2.Add(this.vbox4); - global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox4])); - w40.Position = 1; + // Container child vbox4.Gtk.Box+BoxChild + this.frame2 = new global::Gtk.Frame(); + this.frame2.Name = "frame2"; + this.frame2.ShadowType = ((global::Gtk.ShadowType)(0)); + // Container child frame2.Gtk.Container+ContainerChild + this.GtkAlignment7 = new global::Gtk.Alignment(0F, 0F, 1F, 1F); + this.GtkAlignment7.Name = "GtkAlignment7"; + this.GtkAlignment7.LeftPadding = ((uint)(12)); + // Container child GtkAlignment7.Gtk.Container+ContainerChild + this.vbox7 = new global::Gtk.VBox(); + this.vbox7.Name = "vbox7"; + this.vbox7.Spacing = 6; + // Container child vbox7.Gtk.Box+BoxChild + this.chkVirusTotal = new global::Gtk.CheckButton(); + this.chkVirusTotal.CanFocus = true; + this.chkVirusTotal.Name = "chkVirusTotal"; + this.chkVirusTotal.Label = global::Mono.Unix.Catalog.GetString("Use VirusTotal?"); + this.chkVirusTotal.DrawIndicator = true; + this.chkVirusTotal.UseUnderline = true; + this.vbox7.Add(this.chkVirusTotal); + global::Gtk.Box.BoxChild w40 = ((global::Gtk.Box.BoxChild)(this.vbox7[this.chkVirusTotal])); + w40.Position = 0; w40.Expand = false; w40.Fill = false; - w1.Add(this.hbox2); - global::Gtk.Box.BoxChild w41 = ((global::Gtk.Box.BoxChild)(w1[this.hbox2])); + // Container child vbox7.Gtk.Box+BoxChild + this.hbox4 = new global::Gtk.HBox(); + this.hbox4.Name = "hbox4"; + this.hbox4.Spacing = 6; + // Container child hbox4.Gtk.Box+BoxChild + this.label6 = new global::Gtk.Label(); + this.label6.Name = "label6"; + this.label6.LabelProp = global::Mono.Unix.Catalog.GetString("API Key"); + this.hbox4.Add(this.label6); + global::Gtk.Box.BoxChild w41 = ((global::Gtk.Box.BoxChild)(this.hbox4[this.label6])); w41.Position = 0; w41.Expand = false; w41.Fill = false; + // Container child hbox4.Gtk.Box+BoxChild + this.txtVirusTotal = new global::Gtk.Entry(); + this.txtVirusTotal.Sensitive = false; + this.txtVirusTotal.CanFocus = true; + this.txtVirusTotal.Name = "txtVirusTotal"; + this.txtVirusTotal.IsEditable = true; + this.txtVirusTotal.InvisibleChar = '●'; + this.hbox4.Add(this.txtVirusTotal); + global::Gtk.Box.BoxChild w42 = ((global::Gtk.Box.BoxChild)(this.hbox4[this.txtVirusTotal])); + w42.Position = 1; + // Container child hbox4.Gtk.Box+BoxChild + this.btnVirusTotal = new global::Gtk.Button(); + this.btnVirusTotal.Sensitive = false; + this.btnVirusTotal.CanFocus = true; + this.btnVirusTotal.Name = "btnVirusTotal"; + this.btnVirusTotal.UseUnderline = true; + this.btnVirusTotal.Label = global::Mono.Unix.Catalog.GetString("Test"); + this.hbox4.Add(this.btnVirusTotal); + global::Gtk.Box.BoxChild w43 = ((global::Gtk.Box.BoxChild)(this.hbox4[this.btnVirusTotal])); + w43.Position = 2; + w43.Expand = false; + w43.Fill = false; + this.vbox7.Add(this.hbox4); + global::Gtk.Box.BoxChild w44 = ((global::Gtk.Box.BoxChild)(this.vbox7[this.hbox4])); + w44.Position = 1; + w44.Expand = false; + w44.Fill = false; + // Container child vbox7.Gtk.Box+BoxChild + this.lblVirusTotal = new global::Gtk.Label(); + this.lblVirusTotal.Name = "lblVirusTotal"; + this.lblVirusTotal.LabelProp = global::Mono.Unix.Catalog.GetString("label5"); + this.vbox7.Add(this.lblVirusTotal); + global::Gtk.Box.BoxChild w45 = ((global::Gtk.Box.BoxChild)(this.vbox7[this.lblVirusTotal])); + w45.Position = 2; + w45.Expand = false; + w45.Fill = false; + this.GtkAlignment7.Add(this.vbox7); + this.frame2.Add(this.GtkAlignment7); + this.GtkLabel12 = new global::Gtk.Label(); + this.GtkLabel12.Name = "GtkLabel12"; + this.GtkLabel12.LabelProp = global::Mono.Unix.Catalog.GetString("VirusTotal"); + this.GtkLabel12.UseMarkup = true; + this.frame2.LabelWidget = this.GtkLabel12; + this.vbox4.Add(this.frame2); + global::Gtk.Box.BoxChild w48 = ((global::Gtk.Box.BoxChild)(this.vbox4[this.frame2])); + w48.Position = 2; + w48.Expand = false; + w48.Fill = false; + this.hbox2.Add(this.vbox4); + global::Gtk.Box.BoxChild w49 = ((global::Gtk.Box.BoxChild)(this.hbox2[this.vbox4])); + w49.Position = 1; + w49.Expand = false; + w49.Fill = false; + w1.Add(this.hbox2); + global::Gtk.Box.BoxChild w50 = ((global::Gtk.Box.BoxChild)(w1[this.hbox2])); + w50.Position = 0; + w50.Expand = false; + w50.Fill = false; // Container child vbox5.Gtk.Box+BoxChild this.hbox18 = new global::Gtk.HBox(); this.hbox18.Name = "hbox18"; @@ -464,10 +573,10 @@ namespace osrepodbmgr this.btnCancel.UseUnderline = true; this.btnCancel.Label = "gtk-cancel"; this.hbox18.Add(this.btnCancel); - global::Gtk.Box.BoxChild w42 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnCancel])); - w42.Position = 0; - w42.Expand = false; - w42.Fill = false; + global::Gtk.Box.BoxChild w51 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnCancel])); + w51.Position = 0; + w51.Expand = false; + w51.Fill = false; // Container child hbox18.Gtk.Box+BoxChild this.btnApply = new global::Gtk.Button(); this.btnApply.CanFocus = true; @@ -476,19 +585,19 @@ namespace osrepodbmgr this.btnApply.UseUnderline = true; this.btnApply.Label = "gtk-apply"; this.hbox18.Add(this.btnApply); - global::Gtk.Box.BoxChild w43 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnApply])); - w43.PackType = ((global::Gtk.PackType)(1)); - w43.Position = 1; - w43.Expand = false; - w43.Fill = false; + global::Gtk.Box.BoxChild w52 = ((global::Gtk.Box.BoxChild)(this.hbox18[this.btnApply])); + w52.PackType = ((global::Gtk.PackType)(1)); + w52.Position = 1; + w52.Expand = false; + w52.Fill = false; w1.Add(this.hbox18); - global::Gtk.Box.BoxChild w44 = ((global::Gtk.Box.BoxChild)(w1[this.hbox18])); - w44.Position = 1; - w44.Expand = false; - w44.Fill = false; + global::Gtk.Box.BoxChild w53 = ((global::Gtk.Box.BoxChild)(w1[this.hbox18])); + w53.Position = 1; + w53.Expand = false; + w53.Fill = false; // Internal child osrepodbmgr.dlgSettings.ActionArea - global::Gtk.HButtonBox w45 = this.ActionArea; - w45.Name = "__gtksharp_108_Stetic_TopLevelDialog_ActionArea"; + global::Gtk.HButtonBox w54 = this.ActionArea; + w54.Name = "__gtksharp_108_Stetic_TopLevelDialog_ActionArea"; // Container child __gtksharp_108_Stetic_TopLevelDialog_ActionArea.Gtk.ButtonBox+ButtonBoxChild this.btnDialog = new global::Gtk.Button(); this.btnDialog.CanFocus = true; @@ -496,17 +605,18 @@ namespace osrepodbmgr this.btnDialog.UseUnderline = true; this.btnDialog.Label = global::Mono.Unix.Catalog.GetString("GtkButton"); this.AddActionWidget(this.btnDialog, 0); - global::Gtk.ButtonBox.ButtonBoxChild w46 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w45[this.btnDialog])); - w46.Expand = false; - w46.Fill = false; + global::Gtk.ButtonBox.ButtonBoxChild w55 = ((global::Gtk.ButtonBox.ButtonBoxChild)(w54[this.btnDialog])); + w55.Expand = false; + w55.Fill = false; if((this.Child != null)) { this.Child.ShowAll(); } this.DefaultWidth = 680; - this.DefaultHeight = 250; + this.DefaultHeight = 320; this.lblUnarVersion.Hide(); - w45.Hide(); + this.lblVirusTotal.Hide(); + w54.Hide(); this.Show(); this.btnDatabase.Clicked += new global::System.EventHandler(this.OnBtnDatabaseClicked); this.btnRepository.Clicked += new global::System.EventHandler(this.OnBtnRepositoryClicked); @@ -515,6 +625,8 @@ namespace osrepodbmgr this.chkAntivirus.Toggled += new global::System.EventHandler(this.OnChkAntivirusToggled); this.chkClamd.Toggled += new global::System.EventHandler(this.OnChkClamdToggled); this.btnClamdTest.Clicked += new global::System.EventHandler(this.OnBtnClamdTestClicked); + this.chkVirusTotal.Toggled += new global::System.EventHandler(this.OnChkVirusTotalToggled); + this.btnVirusTotal.Clicked += new global::System.EventHandler(this.OnBtnVirusTotalClicked); this.btnCancel.Clicked += new global::System.EventHandler(this.OnBtnCancelClicked); this.btnApply.Clicked += new global::System.EventHandler(this.OnBtnApplyClicked); } diff --git a/osrepodbmgr/gtk-gui/osrepodbmgr.frmMain.cs b/osrepodbmgr/gtk-gui/osrepodbmgr.frmMain.cs index d46a439..14f05c6 100644 --- a/osrepodbmgr/gtk-gui/osrepodbmgr.frmMain.cs +++ b/osrepodbmgr/gtk-gui/osrepodbmgr.frmMain.cs @@ -93,7 +93,7 @@ namespace osrepodbmgr this.notebook1 = new global::Gtk.Notebook(); this.notebook1.CanFocus = true; this.notebook1.Name = "notebook1"; - this.notebook1.CurrentPage = 1; + this.notebook1.CurrentPage = 0; // Container child notebook1.Gtk.Notebook+NotebookChild this.vbox3 = new global::Gtk.VBox(); this.vbox3.Name = "vbox3";