public void setDROIDVersion(String value) { if (!value.Equals(AnalysisController.getFFITVersion())) { MessageDisplay.GeneralWarning("This file was generated with DROID version " + value + ". Current version is " + AnalysisController.getFFITVersion()); } }
public void setSignatureFileVersion(String value) { try { mySigFileVersion = Convert.ToInt32(value); // Integer.parseInt(value); } catch (InvalidCastException) //NumberFormatException) { MessageDisplay.GeneralWarning("The SigFileVersion attribute should be an integer"); } }
/** Set the interval (in days) after which to check for newer signature file */ public void setSigFileCheckFreq(String theFreq) { try { this.myDownloadFreq = Convert.ToInt32(theFreq); //Integer.parseInt(theFreq); } catch (Exception) { MessageDisplay.GeneralWarning("Unable to read the signature file download frequency\nMake sure that the <SigFileCheckFreq> element in the configuration file is an integer number of days.\nThe default value of " + Convert.ToString(AnalysisController.CONFIG_DOWNLOAD_FREQ) + " days will be used"); //Integer.toString(AnalysisController.CONFIG_DOWNLOAD_FREQ) + " days will be used"); } }
/** Set the proxy server port */ public void setProxyPort(String theProxyPort) { if (theProxyPort.Trim().Length > 0) { try { this.myProxyPort = Convert.ToInt32(theProxyPort); //Integer.parseInt(theProxyPort); } catch (System.FormatException) // NumberFormatException { //the port number is not translatable to an integer this.myProxyPort = 0; MessageDisplay.GeneralWarning("Unable to read the proxy server port settings\nMake sure that the <ProxyPort> element in the configuration file is an integer."); } } }
/** * Populate the details of the IdentificationFile object when read in from XML file. * @param theName Name of the attribute read in * @param theValue Value of the attribute read in */ public void setAttributeValue(string theName, string theValue) { if (theName.Equals("Name")) { this.setFilePath(theValue); } else if (theName.Equals("IdentQuality")) { //The IdentQuality attribute value should match one of those specified in code - //otherwise show a warning if (theValue.Equals(AnalysisController.FILE_CLASSIFICATION_POSITIVE_TEXT)) { myIDStatus = AnalysisController.FILE_CLASSIFICATION_POSITIVE; } else if (theValue.Equals(AnalysisController.FILE_CLASSIFICATION_TENTATIVE_TEXT)) { myIDStatus = AnalysisController.FILE_CLASSIFICATION_TENTATIVE; } else if (theValue.Equals(AnalysisController.FILE_CLASSIFICATION_NOHIT_TEXT)) { myIDStatus = AnalysisController.FILE_CLASSIFICATION_NOHIT; } else if (theValue.Equals(AnalysisController.FILE_CLASSIFICATION_ERROR_TEXT)) { myIDStatus = AnalysisController.FILE_CLASSIFICATION_ERROR; } else if (theValue.Equals(AnalysisController.FILE_CLASSIFICATION_NOTCLASSIFIED_TEXT)) { myIDStatus = AnalysisController.FILE_CLASSIFICATION_NOTCLASSIFIED; } else { MessageDisplay.GeneralWarning("Unknown file status listed: <" + theValue + "> is not the same as <" + AnalysisController.FILE_CLASSIFICATION_POSITIVE_TEXT + ">"); } } else if (theName.Equals("Warning")) { this.setWarning(theValue); } else { MessageDisplay.UnknownAttributeWarning(theName, this.GetElementName()); } }
/** * Set hit status. Used by XML reader for IdentificationFile/FileFormatHit/Status element */ public void SetStatus(String value) { //String value = element.getText(); if (value.Equals(AnalysisController.HIT_TYPE_POSITIVE_GENERIC_TEXT)) { myHitType = AnalysisController.HIT_TYPE_POSITIVE_GENERIC; } else if (value.Equals(AnalysisController.HIT_TYPE_POSITIVE_SPECIFIC_TEXT)) { myHitType = AnalysisController.HIT_TYPE_POSITIVE_SPECIFIC; } else if (value.Equals(AnalysisController.HIT_TYPE_TENTATIVE_TEXT)) { myHitType = AnalysisController.HIT_TYPE_TENTATIVE; } else if (value.Equals(AnalysisController.HIT_TYPE_POSITIVE_GENERIC_OR_SPECIFIC_TEXT)) { myHitType = AnalysisController.HIT_TYPE_POSITIVE_GENERIC_OR_SPECIFIC; } else { MessageDisplay.GeneralWarning("Unknown hit status listed: " + value); } }
/** * Adds an element/elements to the collection * If filepath is a path to file then add that file * If filepath is a folder path then add contents of the folder * * @param theFile Filepath of file or folder * @param isRecursive if true add all subfolders and subsubfolders , etc */ public void addFile(string theFile, bool isRecursive) { if (UrlByteReader.isURL(theFile)) { if (!this.isDuplicate(theFile)) { //File object is a URL: add if it isn't a duplicate myFiles.Add(new IdentificationFile(theFile)); } return; } if (InputStreamByteReader.isInputStream(theFile)) { if (!this.isDuplicate(theFile)) { // File is a the input stram: add if it isn't a duplicate myFiles.Add(new IdentificationFile(theFile)); } } try { //java.io.File f = new java.io.File(theFile); System.IO.FileInfo f = new System.IO.FileInfo(theFile); //Is file object a directory or file? if (System.IO.Directory.Exists(theFile)) //f.isDirectory()) { //File object is a directory/folder //Iterate through directory ,create IdentificationFile objects //and add them to the collection //java.io.File[] folderFiles = f.listFiles(); System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(theFile); System.IO.FileInfo[] folderFiles = d.GetFiles(); int numFiles = 0; try { numFiles = folderFiles.Length; } catch (Exception) { MessageDisplay.GeneralWarning("Unable to read directory " + theFile + "\nThis may be because you do not have the correct permissions."); } for (int m = 0; m < numFiles; m++) { if (System.IO.Directory.Exists(folderFiles[m].FullName)) //folderFiles[m].isFile()) { //If file exists and not duplicate then add if (!this.isDuplicate(folderFiles[m].FullName)) { IdentificationFile idFile = new IdentificationFile(folderFiles[m].FullName); myFiles.Add(idFile); } } else if (System.IO.Directory.Exists(folderFiles[m].FullName) && isRecursive) { //If subdirectory found and recursive is on add contents of that folder addFile(folderFiles[m].FullName, isRecursive); } } } else if (!System.IO.Directory.Exists(f.FullName)) //f.isFile()) { if (!this.isDuplicate(f.FullName)) { //File object is a File then add file if it isn't a duplicate IdentificationFile idFile = new IdentificationFile(f.FullName); myFiles.Add(idFile); } } } catch (Exception e) { MessageDisplay.GeneralWarning("The following error occured while adding " + theFile + ":\n" + e.ToString()); } }