idx int64 0 41.2k | question stringlengths 73 5.81k | target stringlengths 5 918 |
|---|---|---|
11,400 | public void addReference ( String referenceSource , String referenceName , String referenceUrl ) { final Reference ref = new Reference ( ) ; ref . setSource ( referenceSource ) ; ref . setName ( referenceName ) ; ref . setUrl ( referenceUrl ) ; this . references . add ( ref ) ; } | Adds a reference . |
11,401 | public List < VulnerableSoftware > getVulnerableSoftware ( boolean sorted ) { final List < VulnerableSoftware > sortedVulnerableSoftware = new ArrayList < > ( this . vulnerableSoftware ) ; if ( sorted ) { Collections . sort ( sortedVulnerableSoftware ) ; } return sortedVulnerableSoftware ; } | Returns a sorted list of vulnerable software . This is primarily used for display within reports . |
11,402 | public int compareTo ( Vulnerability v ) { return new CompareToBuilder ( ) . append ( this . name , v . name ) . toComparison ( ) ; } | Compares two vulnerabilities . |
11,403 | private static boolean artifactsMatch ( org . apache . maven . model . Dependency d , Artifact a ) { return isEqualOrNull ( a . getArtifactId ( ) , d . getArtifactId ( ) ) && isEqualOrNull ( a . getGroupId ( ) , d . getGroupId ( ) ) && isEqualOrNull ( a . getVersion ( ) , d . getVersion ( ) ) ; } | Determines if the groupId artifactId and version of the Maven dependency and artifact match . |
11,404 | private static boolean isEqualOrNull ( String left , String right ) { return ( left != null && left . equals ( right ) ) || ( left == null && right == null ) ; } | Compares two strings for equality ; if both strings are null they are considered equal . |
11,405 | public void execute ( ) throws MojoExecutionException , MojoFailureException { generatingSite = false ; final boolean shouldSkip = Boolean . parseBoolean ( System . getProperty ( "dependency-check.skip" , Boolean . toString ( skip ) ) ) ; if ( shouldSkip ) { getLog ( ) . info ( "Skipping " + getName ( Locale . US ) ) ;... | Executes dependency - check . |
11,406 | protected File getCorrectOutputDirectory ( MavenProject current ) { final Object obj = current . getContextValue ( "dependency-check-output-dir" ) ; if ( obj != null && obj instanceof File ) { return ( File ) obj ; } File target = new File ( current . getBuild ( ) . getDirectory ( ) ) ; if ( target . getParentFile ( ) ... | Returns the correct output directory depending on if a site is being executed or not . |
11,407 | private DependencyNode toDependencyNode ( ProjectBuildingRequest buildingRequest , DependencyNode parent , org . apache . maven . model . Dependency dependency ) throws ArtifactResolverException { final DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate ( ) ; coordinate . setGroupId ( dependency . get... | Converts the dependency to a dependency node object . |
11,408 | private ExceptionCollection collectDependencyManagementDependencies ( ProjectBuildingRequest buildingRequest , MavenProject project , List < DependencyNode > nodes , boolean aggregate ) { if ( skipDependencyManagement || project . getDependencyManagement ( ) == null ) { return null ; } ExceptionCollection exCol = null ... | Collect dependencies from the dependency management section . |
11,409 | protected void runCheck ( ) throws MojoExecutionException , MojoFailureException { try ( Engine engine = initializeEngine ( ) ) { ExceptionCollection exCol = scanDependencies ( engine ) ; try { engine . analyzeDependencies ( ) ; } catch ( ExceptionCollection ex ) { exCol = handleAnalysisExceptions ( exCol , ex ) ; } if... | Executes the dependency - check scan and generates the necessary report . |
11,410 | private ExceptionCollection handleAnalysisExceptions ( ExceptionCollection currentEx , ExceptionCollection newEx ) throws MojoExecutionException { ExceptionCollection returnEx = currentEx ; if ( returnEx == null ) { returnEx = newEx ; } else { returnEx . getExceptions ( ) . addAll ( newEx . getExceptions ( ) ) ; if ( n... | Combines the two exception collections and if either are fatal throw an MojoExecutionException |
11,411 | public String getOutputName ( ) { if ( "HTML" . equalsIgnoreCase ( this . format ) || "ALL" . equalsIgnoreCase ( this . format ) ) { return "dependency-check-report" ; } else if ( "XML" . equalsIgnoreCase ( this . format ) ) { return "dependency-check-report.xml" ; } else if ( "JUNIT" . equalsIgnoreCase ( this . format... | Returns the output name . |
11,412 | private String decryptServerPassword ( Server server ) throws SecDispatcherException { if ( securityDispatcher instanceof DefaultSecDispatcher ) { ( ( DefaultSecDispatcher ) securityDispatcher ) . setConfigurationFile ( "~/.m2/settings-security.xml" ) ; } return securityDispatcher . decrypt ( server . getPassword ( ) )... | Obtains the configured password for the given server . |
11,413 | private String [ ] determineSuppressions ( ) { String [ ] suppressions = suppressionFiles ; if ( suppressionFile != null ) { if ( suppressions == null ) { suppressions = new String [ ] { suppressionFile } ; } else { suppressions = Arrays . copyOf ( suppressions , suppressions . length + 1 ) ; suppressions [ suppression... | Combines the configured suppressionFile and suppressionFiles into a single array . |
11,414 | private Proxy getMavenProxy ( ) { if ( mavenSettings != null ) { final List < Proxy > proxies = mavenSettings . getProxies ( ) ; if ( proxies != null && ! proxies . isEmpty ( ) ) { if ( mavenSettingsProxyId != null ) { for ( Proxy proxy : proxies ) { if ( mavenSettingsProxyId . equalsIgnoreCase ( proxy . getId ( ) ) ) ... | Returns the maven proxy . |
11,415 | private String determineEcosystem ( String baseEcosystem , String vendor , String product , String targetSw ) { if ( "ibm" . equals ( vendor ) && "java" . equals ( product ) ) { return "c/c++" ; } if ( "oracle" . equals ( vendor ) && "vm" . equals ( product ) ) { return "c/c++" ; } if ( "*" . equals ( targetSw ) || bas... | Attempts to determine the ecosystem based on the vendor product and targetSw . |
11,416 | private String determineDatabaseProductName ( Connection conn ) { try { final String databaseProductName = conn . getMetaData ( ) . getDatabaseProductName ( ) . toLowerCase ( ) ; LOGGER . debug ( "Database product: {}" , databaseProductName ) ; return databaseProductName ; } catch ( SQLException se ) { LOGGER . warn ( ... | Tries to determine the product name of the database . |
11,417 | private synchronized void open ( ) throws DatabaseException { try { if ( ! isOpen ( ) ) { connection = connectionFactory . getConnection ( ) ; final String databaseProductName = determineDatabaseProductName ( this . connection ) ; statementBundle = databaseProductName != null ? ResourceBundle . getBundle ( "data/dbStat... | Opens the database connection . If the database does not exist it will create a new one . |
11,418 | public synchronized void close ( ) { if ( isOpen ( ) ) { clearCache ( ) ; closeStatements ( ) ; try { connection . close ( ) ; } catch ( SQLException ex ) { LOGGER . error ( "There was an error attempting to close the CveDB, see the log for more details." ) ; LOGGER . debug ( "" , ex ) ; } catch ( Throwable ex ) { LOGG... | Closes the database connection . Close should be called on this object when it is done being used . |
11,419 | private void prepareStatements ( ) throws DatabaseException { for ( PreparedStatementCveDb key : values ( ) ) { PreparedStatement preparedStatement = null ; try { final String statementString = statementBundle . getString ( key . name ( ) ) ; if ( key == INSERT_VULNERABILITY || key == INSERT_CPE ) { preparedStatement =... | Prepares all statements to be used . |
11,420 | private PreparedStatement prepareStatement ( PreparedStatementCveDb key ) throws DatabaseException { PreparedStatement preparedStatement = null ; try { final String statementString = statementBundle . getString ( key . name ( ) ) ; if ( key == INSERT_VULNERABILITY || key == INSERT_CPE ) { preparedStatement = connection... | Creates a prepared statement from the given key . The SQL is stored in a properties file and the key is used to lookup the specific query . |
11,421 | private HttpURLConnection connect ( URL url ) throws IOException { LOGGER . debug ( "Searching Artifactory url {}" , url ) ; final URLConnectionFactory factory = new URLConnectionFactory ( settings ) ; final HttpURLConnection conn = factory . createHttpURLConnection ( url , useProxy ) ; conn . setDoOutput ( true ) ; co... | Makes an connection to the given URL . |
11,422 | protected List < MavenArtifact > processResponse ( Dependency dependency , HttpURLConnection conn ) throws IOException { final JsonObject asJsonObject ; try ( final InputStreamReader streamReader = new InputStreamReader ( conn . getInputStream ( ) , StandardCharsets . UTF_8 ) ) { asJsonObject = new JsonParser ( ) . par... | Process the Artifactory response . |
11,423 | private void checkHashes ( Dependency dependency , String sha1 , String sha256 , String md5 ) throws FileNotFoundException { final String md5sum = dependency . getMd5sum ( ) ; if ( ! md5 . equals ( md5sum ) ) { throw new FileNotFoundException ( "Artifact found by API is not matching the md5 " + "of the artifact (reposi... | Validates the hashes of the dependency . |
11,424 | public boolean preflightRequest ( ) { try { final URL url = buildUrl ( Checksum . getSHA1Checksum ( UUID . randomUUID ( ) . toString ( ) ) ) ; final HttpURLConnection connection = connect ( url ) ; if ( connection . getResponseCode ( ) != 200 ) { LOGGER . warn ( "Expected 200 result from Artifactory ({}), got {}" , url... | Performs a pre - flight request to ensure the Artifactory service is reachable . |
11,425 | @ SuppressFBWarnings ( justification = "try with resources will clean up the input stream" , value = { "OBL_UNSATISFIED_OBLIGATION" } ) public AssemblyData parse ( File file ) throws GrokParseException { try ( FileInputStream fis = new FileInputStream ( file ) ) { return parse ( fis ) ; } catch ( IOException ex ) { LOG... | Parses the given XML file and returns the assembly data . |
11,426 | public AssemblyData parse ( InputStream inputStream ) throws GrokParseException { try ( InputStream schema = FileUtils . getResourceAsStream ( GROK_SCHEMA ) ) { final GrokHandler handler = new GrokHandler ( ) ; final SAXParser saxParser = XmlUtils . buildSecureSaxParser ( schema ) ; final XMLReader xmlReader = saxParse... | Parses the given XML stream and returns the contained assembly data . |
11,427 | protected void runCheck ( ) throws MojoExecutionException , MojoFailureException { try ( Engine engine = initializeEngine ( ) ) { try { if ( ! engine . getSettings ( ) . getBoolean ( Settings . KEYS . AUTO_UPDATE ) ) { engine . getSettings ( ) . setBoolean ( Settings . KEYS . AUTO_UPDATE , true ) ; } } catch ( InvalidS... | Executes the dependency - check engine on the project s dependencies and generates the report . |
11,428 | protected Dependency createDependency ( Dependency dependency , String name , String version , String scope ) { final Dependency nodeModule = new Dependency ( new File ( dependency . getActualFile ( ) + "?" + name ) , true ) ; nodeModule . setEcosystem ( NPM_DEPENDENCY_ECOSYSTEM ) ; nodeModule . setSha1sum ( Checksum .... | Construct a dependency object . |
11,429 | public static Model readPom ( File file ) throws AnalysisException { try { final PomParser parser = new PomParser ( ) ; final Model model = parser . parse ( file ) ; if ( model == null ) { throw new AnalysisException ( String . format ( "Unable to parse pom '%s'" , file . getPath ( ) ) ) ; } return model ; } catch ( An... | Reads in the specified POM and converts it to a Model . |
11,430 | public static Model readPom ( String path , JarFile jar ) throws AnalysisException { final ZipEntry entry = jar . getEntry ( path ) ; Model model = null ; if ( entry != null ) { try { final PomParser parser = new PomParser ( ) ; model = parser . parse ( jar . getInputStream ( entry ) ) ; if ( model == null ) { throw ne... | Retrieves the specified POM from a jar file and converts it to a Model . |
11,431 | public static void analyzePOM ( Dependency dependency , File pomFile ) throws AnalysisException { final Model pom = PomUtils . readPom ( pomFile ) ; JarAnalyzer . setPomEvidence ( dependency , pom , null , true ) ; } | Reads in the pom file and adds elements as evidence to the given dependency . |
11,432 | public synchronized void prepareAnalyzer ( Engine engine ) throws InitializationException { if ( rules . isEmpty ( ) ) { try { loadSuppressionBaseData ( ) ; } catch ( SuppressionParseException ex ) { throw new InitializationException ( "Error initializing the suppression analyzer: " + ex . getLocalizedMessage ( ) , ex ... | The prepare method loads the suppression XML file . |
11,433 | public static void cleanup ( Driver driver ) { try { DriverManager . deregisterDriver ( driver ) ; } catch ( SQLException ex ) { LOGGER . debug ( "An error occurred unloading the database driver" , ex ) ; } catch ( Throwable unexpected ) { LOGGER . debug ( "An unexpected throwable occurred unloading the database driver... | De - registers the driver . |
11,434 | public static Driver load ( String className ) throws DriverLoadException { final ClassLoader loader = DriverLoader . class . getClassLoader ( ) ; return load ( className , loader ) ; } | Loads the specified class using the system class loader and registers the driver with the driver manager . |
11,435 | @ SuppressWarnings ( "StringSplitter" ) public static Driver load ( String className , String pathToDriver ) throws DriverLoadException { final ClassLoader parent = ClassLoader . getSystemClassLoader ( ) ; final List < URL > urls = new ArrayList < > ( ) ; final String [ ] paths = pathToDriver . split ( File . pathSepar... | Loads the specified class by registering the supplied paths to the class loader and then registers the driver with the driver manager . The pathToDriver argument is added to the class loader so that an external driver can be loaded . Note the pathToDriver can contain a semi - colon separated list of paths so any depend... |
11,436 | private static Driver load ( String className , ClassLoader loader ) throws DriverLoadException { try { final Class < ? > c = Class . forName ( className , true , loader ) ; final Driver driver = ( Driver ) c . getDeclaredConstructor ( ) . newInstance ( ) ; final Driver shim = new DriverShim ( driver ) ; DriverManager ... | Loads the specified class using the supplied class loader and registers the driver with the driver manager . |
11,437 | private VelocityContext createContext ( String applicationName , List < Dependency > dependencies , List < Analyzer > analyzers , DatabaseProperties properties ) { final DateTime dt = new DateTime ( ) ; final DateTimeFormatter dateFormat = DateTimeFormat . forPattern ( "MMM d, yyyy 'at' HH:mm:ss z" ) ; final DateTimeFo... | Constructs the velocity context used to generate the dependency - check reports . |
11,438 | public void write ( String outputLocation , String format ) throws ReportException { Format reportFormat = null ; try { reportFormat = Format . valueOf ( format . toUpperCase ( ) ) ; } catch ( IllegalArgumentException ex ) { LOGGER . trace ( "ignore this exception" , ex ) ; } if ( reportFormat != null ) { write ( outpu... | Writes the dependency - check report to the given output location . |
11,439 | protected File getReportFile ( String outputLocation , Format format ) { File outFile = new File ( outputLocation ) ; if ( outFile . getParentFile ( ) == null ) { outFile = new File ( "." , outputLocation ) ; } final String pathToCheck = outputLocation . toLowerCase ( ) ; if ( format == Format . XML && ! pathToCheck . ... | Determines the report file name based on the give output location and format . If the output location contains a full file name that has the correct extension for the given report type then the output location is returned . However if the output location is a directory this method will generate the correct name for the... |
11,440 | private void ensureParentDirectoryExists ( File file ) throws ReportException { if ( ! file . getParentFile ( ) . exists ( ) ) { final boolean created = file . getParentFile ( ) . mkdirs ( ) ; if ( ! created ) { final String msg = String . format ( "Unable to create directory '%s'." , file . getParentFile ( ) . getAbso... | Validates that the given file s parent directory exists . If the directory does not exist an attempt to create the necessary path is made ; if that fails a ReportException will be raised . |
11,441 | private void pretifyJson ( String pathToJson ) throws ReportException { final String outputPath = pathToJson + ".pretty" ; final File in = new File ( pathToJson ) ; final File out = new File ( outputPath ) ; try ( JsonReader reader = new JsonReader ( new InputStreamReader ( new FileInputStream ( in ) , StandardCharsets... | Reformats the given JSON file . |
11,442 | private static void prettyPrint ( JsonReader reader , JsonWriter writer ) throws IOException { writer . setIndent ( " " ) ; while ( true ) { final JsonToken token = reader . peek ( ) ; switch ( token ) { case BEGIN_ARRAY : reader . beginArray ( ) ; writer . beginArray ( ) ; break ; case END_ARRAY : reader . endArray (... | Streams from a json reader to a json writer and performs pretty printing . |
11,443 | private Process launchBundleAudit ( File folder ) throws AnalysisException { if ( ! folder . isDirectory ( ) ) { throw new AnalysisException ( String . format ( "%s should have been a directory." , folder . getAbsolutePath ( ) ) ) ; } final List < String > args = new ArrayList < > ( ) ; final String bundleAuditPath = g... | Launch bundle - audit . |
11,444 | public void prepareFileTypeAnalyzer ( Engine engine ) throws InitializationException { if ( engine != null ) { this . cvedb = engine . getDatabase ( ) ; } Process process = null ; try { process = launchBundleAudit ( getSettings ( ) . getTempDirectory ( ) ) ; } catch ( AnalysisException ae ) { setEnabled ( false ) ; fin... | Initialize the analyzer . |
11,445 | protected void analyzeDependency ( Dependency dependency , Engine engine ) throws AnalysisException { if ( needToDisableGemspecAnalyzer ) { boolean failed = true ; final String className = RubyGemspecAnalyzer . class . getName ( ) ; for ( FileTypeAnalyzer analyzer : engine . getFileTypeAnalyzers ( ) ) { if ( analyzer i... | Determines if the analyzer can analyze the given file type . |
11,446 | private void processBundlerAuditOutput ( Dependency original , Engine engine , BufferedReader rdr ) throws IOException , CpeValidationException { final String parentName = original . getActualFile ( ) . getParentFile ( ) . getName ( ) ; final String fileName = original . getFileName ( ) ; final String filePath = origin... | Processes the bundler audit output . |
11,447 | private void setVulnerabilityName ( String parentName , Dependency dependency , Vulnerability vulnerability , String nextLine ) { final String advisory = nextLine . substring ( ADVISORY . length ( ) ) ; if ( null != vulnerability ) { vulnerability . setName ( advisory ) ; } if ( null != dependency ) { dependency . addV... | Sets the vulnerability name . |
11,448 | private void addReferenceToVulnerability ( String parentName , Vulnerability vulnerability , String nextLine ) { final String url = nextLine . substring ( "URL: " . length ( ) ) ; if ( null != vulnerability ) { final Reference ref = new Reference ( ) ; ref . setName ( vulnerability . getName ( ) ) ; ref . setSource ( "... | Adds a reference to the vulnerability . |
11,449 | private void addCriticalityToVulnerability ( String parentName , Vulnerability vulnerability , String nextLine ) { if ( null != vulnerability ) { final String criticality = nextLine . substring ( CRITICALITY . length ( ) ) . trim ( ) ; float score = - 1.0f ; Vulnerability v = null ; if ( cvedb != null ) { try { v = cve... | Adds the criticality to the vulnerability |
11,450 | private Vulnerability createVulnerability ( String parentName , Dependency dependency , String gem , String nextLine ) throws CpeValidationException { Vulnerability vulnerability = null ; if ( null != dependency ) { final String version = nextLine . substring ( VERSION . length ( ) ) ; dependency . addEvidence ( Eviden... | Creates a vulnerability . |
11,451 | private Dependency createDependencyForGem ( Engine engine , String parentName , String fileName , String filePath , String gem ) throws IOException { final File gemFile ; try { gemFile = File . createTempFile ( gem , "_Gemfile.lock" , getSettings ( ) . getTempDirectory ( ) ) ; } catch ( IOException ioe ) { throw new IO... | Creates the dependency based off of the gem . |
11,452 | @ SuppressFBWarnings ( justification = "try with resources will clean up the input stream" , value = { "OBL_UNSATISFIED_OBLIGATION" } ) public void parseHints ( File file ) throws HintParseException { try ( InputStream fis = new FileInputStream ( file ) ) { parseHints ( fis ) ; } catch ( SAXException | IOException ex )... | Parses the given XML file and returns a list of the hints contained . |
11,453 | public void parseHints ( InputStream inputStream ) throws HintParseException , SAXException { try ( InputStream schemaStream13 = FileUtils . getResourceAsStream ( HINT_SCHEMA_1_3 ) ; InputStream schemaStream12 = FileUtils . getResourceAsStream ( HINT_SCHEMA_1_2 ) ; InputStream schemaStream11 = FileUtils . getResourceAs... | Parses the given XML stream and returns a list of the hint rules contained . |
11,454 | protected void reset ( ) { super . reset ( ) ; versionEndExcluding = null ; versionEndIncluding = null ; versionStartExcluding = null ; versionStartIncluding = null ; vulnerable = true ; } | Resets the Vulnerable Software Builder to a clean state . |
11,455 | public VulnerableSoftwareBuilder cpe ( Cpe cpe ) { this . part ( cpe . getPart ( ) ) . wfVendor ( cpe . getWellFormedVendor ( ) ) . wfProduct ( cpe . getWellFormedProduct ( ) ) . wfVersion ( cpe . getWellFormedVersion ( ) ) . wfUpdate ( cpe . getWellFormedUpdate ( ) ) . wfEdition ( cpe . getWellFormedEdition ( ) ) . wf... | Adds a base CPE object to build a vulnerable software object from . |
11,456 | public List < Analyzer > getAnalyzers ( List < AnalysisPhase > phases ) { final List < Analyzer > analyzers = new ArrayList < > ( ) ; final Iterator < Analyzer > iterator = service . iterator ( ) ; boolean experimentalEnabled = false ; boolean retiredEnabled = false ; try { experimentalEnabled = settings . getBoolean (... | Returns a list of all instances of the Analyzer interface that are bound to one of the given phases . |
11,457 | public List < Advisory > parse ( JSONObject jsonResponse ) { LOGGER . debug ( "Parsing JSON node" ) ; final List < Advisory > advisories = new ArrayList < > ( ) ; final JSONObject jsonAdvisories = jsonResponse . getJSONObject ( "advisories" ) ; final Iterator < ? > keys = jsonAdvisories . keys ( ) ; while ( keys . hasN... | Parses the JSON response from the NPM Audit API . |
11,458 | private Advisory parseAdvisory ( JSONObject object ) { final Advisory advisory = new Advisory ( ) ; advisory . setId ( object . getInt ( "id" ) ) ; advisory . setOverview ( object . optString ( "overview" , null ) ) ; advisory . setReferences ( object . optString ( "references" , null ) ) ; advisory . setCreated ( obje... | Parses the advisory from Node Audit . |
11,459 | public boolean matchesAtLeastThreeLevels ( DependencyVersion version ) { if ( version == null ) { return false ; } if ( Math . abs ( this . versionParts . size ( ) - version . versionParts . size ( ) ) >= 3 ) { return false ; } final int max = ( this . versionParts . size ( ) < version . versionParts . size ( ) ) ? thi... | Determines if the three most major major version parts are identical . For instances if version 1 . 2 . 3 . 4 was compared to 1 . 2 . 3 this function would return true . |
11,460 | @ SuppressFBWarnings ( justification = "try with resource will clenaup the resources" , value = { "OBL_UNSATISFIED_OBLIGATION" } ) public List < SuppressionRule > parseSuppressionRules ( File file ) throws SuppressionParseException { try ( FileInputStream fis = new FileInputStream ( file ) ) { return parseSuppressionRu... | Parses the given XML file and returns a list of the suppression rules contained . |
11,461 | public List < SuppressionRule > parseSuppressionRules ( InputStream inputStream ) throws SuppressionParseException , SAXException { try ( InputStream schemaStream12 = FileUtils . getResourceAsStream ( SUPPRESSION_SCHEMA_1_2 ) ; InputStream schemaStream11 = FileUtils . getResourceAsStream ( SUPPRESSION_SCHEMA_1_1 ) ; In... | Parses the given XML stream and returns a list of the suppression rules contained . |
11,462 | public InputStream fetch ( URL url ) throws DownloadFailedException { if ( "file" . equalsIgnoreCase ( url . getProtocol ( ) ) ) { final File file ; try { file = new File ( url . toURI ( ) ) ; } catch ( URISyntaxException ex ) { final String msg = format ( "Download failed, unable to locate '%s'" , url . toString ( ) )... | Retrieves the resource identified by the given URL and returns the InputStream . |
11,463 | private HttpURLConnection obtainConnection ( URL url ) throws DownloadFailedException { HttpURLConnection conn = null ; try { LOGGER . debug ( "Attempting retrieval of {}" , url . toString ( ) ) ; conn = connFactory . createHttpURLConnection ( url , this . usesProxy ) ; conn . setRequestProperty ( "Accept-Encoding" , "... | Obtains the HTTP URL Connection . |
11,464 | private boolean isQuickQuery ( ) { boolean quickQuery ; try { quickQuery = settings . getBoolean ( Settings . KEYS . DOWNLOADER_QUICK_QUERY_TIMESTAMP , true ) ; } catch ( InvalidSettingException e ) { if ( LOGGER . isTraceEnabled ( ) ) { LOGGER . trace ( "Invalid settings : {}" , e . getMessage ( ) , e ) ; } quickQuery... | Determines if the HTTP method GET or HEAD should be used to check the timestamp on external resources . |
11,465 | public void checkForCommonExceptionTypes ( IOException ex ) throws DownloadFailedException { Throwable cause = ex ; while ( cause != null ) { if ( cause instanceof java . net . UnknownHostException ) { final String msg = format ( "Unable to resolve domain '%s'" , cause . getMessage ( ) ) ; LOGGER . error ( msg ) ; thro... | Analyzes the IOException logs the appropriate information for debugging purposes and then throws a DownloadFailedException that wraps the IO Exception for common IO Exceptions . This is to provide additional details to assist in resolution of the exception . |
11,466 | public void remove ( ) { try { Runtime . getRuntime ( ) . removeShutdownHook ( this ) ; } catch ( IllegalStateException ex ) { LOGGER . trace ( "ignore as we are likely shutting down" , ex ) ; } } | Removes the shutdown hook . |
11,467 | public boolean canGenerateReport ( ) { populateSettings ( ) ; boolean isCapable = false ; for ( Artifact a : getProject ( ) . getArtifacts ( ) ) { if ( ! getArtifactScopeExcluded ( ) . passes ( a . getScope ( ) ) ) { isCapable = true ; break ; } } return isCapable ; } | Returns whether or not a the report can be generated . |
11,468 | private void skipToProject ( ) throws IOException { final byte [ ] buffer = new byte [ BUFFER_SIZE ] ; super . mark ( BUFFER_SIZE ) ; int count = super . read ( buffer , 0 , BUFFER_SIZE ) ; while ( count > 0 ) { final int pos = findSequence ( PROJECT , buffer ) ; if ( pos >= 0 ) { super . reset ( ) ; super . skip ( pos... | Skips bytes from the input stream until it finds the < ; project> ; element . |
11,469 | protected static int findSequence ( byte [ ] sequence , byte [ ] buffer ) { int pos = - 1 ; for ( int i = 0 ; i < buffer . length - sequence . length + 1 ; i ++ ) { if ( buffer [ i ] == sequence [ 0 ] && testRemaining ( sequence , buffer , i ) ) { pos = i ; break ; } } return pos ; } | Finds the start of the given sequence in the buffer . If not found - 1 is returned . |
11,470 | public void addGivenProduct ( String source , String name , String value , boolean regex , Confidence confidence ) { givenProduct . add ( new EvidenceMatcher ( source , name , value , regex , confidence ) ) ; } | Adds a given product to the list of evidence to matched . |
11,471 | public void addGivenVendor ( String source , String name , String value , boolean regex , Confidence confidence ) { givenVendor . add ( new EvidenceMatcher ( source , name , value , regex , confidence ) ) ; } | Adds a given vendors to the list of evidence to matched . |
11,472 | public void addAddProduct ( String source , String name , String value , Confidence confidence ) { addProduct . add ( new Evidence ( source , name , value , confidence ) ) ; } | Adds a given product to the list of evidence to add when matched . |
11,473 | public void addAddVersion ( String source , String name , String value , Confidence confidence ) { addVersion . add ( new Evidence ( source , name , value , confidence ) ) ; } | Adds a given version to the list of evidence to add when matched . |
11,474 | public void addAddVendor ( String source , String name , String value , Confidence confidence ) { addVendor . add ( new Evidence ( source , name , value , confidence ) ) ; } | Adds a given vendor to the list of evidence to add when matched . |
11,475 | public void addRemoveVendor ( String source , String name , String value , boolean regex , Confidence confidence ) { removeVendor . add ( new EvidenceMatcher ( source , name , value , regex , confidence ) ) ; } | Adds a given vendor to the list of evidence to remove when matched . |
11,476 | public void addRemoveProduct ( String source , String name , String value , boolean regex , Confidence confidence ) { removeProduct . add ( new EvidenceMatcher ( source , name , value , regex , confidence ) ) ; } | Adds a given product to the list of evidence to remove when matched . |
11,477 | public void addRemoveVersion ( String source , String name , String value , boolean regex , Confidence confidence ) { removeVersion . add ( new EvidenceMatcher ( source , name , value , regex , confidence ) ) ; } | Adds a given version to the list of evidence to remove when matched . |
11,478 | public void addGivenVersion ( String source , String name , String value , boolean regex , Confidence confidence ) { givenVersion . add ( new EvidenceMatcher ( source , name , value , regex , confidence ) ) ; } | Adds a given version to the list of evidence to match . |
11,479 | public static void extractFiles ( File archive , File extractTo , Engine engine ) throws ExtractionException { if ( archive == null || extractTo == null ) { return ; } final String destPath ; try { destPath = extractTo . getCanonicalPath ( ) ; } catch ( IOException ex ) { throw new ExtractionException ( "Unable to extr... | Extracts the contents of an archive into the specified directory . The files are only extracted if they are supported by the analyzers loaded into the specified engine . If the engine is specified as null then all files are extracted . |
11,480 | private static void extractArchive ( ArchiveInputStream input , File destination , FilenameFilter filter ) throws ArchiveExtractionException { ArchiveEntry entry ; try { final String destPath = destination . getCanonicalPath ( ) ; while ( ( entry = input . getNextEntry ( ) ) != null ) { if ( entry . isDirectory ( ) ) {... | Extracts files from an archive . |
11,481 | private static void createParentFile ( final File file ) throws ExtractionException { final File parent = file . getParentFile ( ) ; if ( ! parent . isDirectory ( ) && ! parent . mkdirs ( ) ) { final String msg = String . format ( "Unable to build directory '%s'." , parent . getAbsolutePath ( ) ) ; throw new Extraction... | Ensures the parent path is correctly created on disk so that the file can be extracted to the correct location . |
11,482 | public static void extractGzip ( File file ) throws FileNotFoundException , IOException { final String originalPath = file . getPath ( ) ; final File gzip = new File ( originalPath + ".gz" ) ; if ( gzip . isFile ( ) && ! gzip . delete ( ) ) { LOGGER . debug ( "Failed to delete initial temporary file when extracting 'gz... | Extracts the file contained in a gzip archive . The extracted file is placed in the exact same path as the file specified . |
11,483 | public static void extractZip ( File file ) throws FileNotFoundException , IOException { final String originalPath = file . getPath ( ) ; final File zip = new File ( originalPath + ".zip" ) ; if ( zip . isFile ( ) && ! zip . delete ( ) ) { LOGGER . debug ( "Failed to delete initial temporary file when extracting 'zip' ... | Extracts the file contained in a Zip archive . The extracted file is placed in the exact same path as the file specified . |
11,484 | public List < NugetPackageReference > parse ( InputStream stream ) throws MSBuildProjectParseException { try { final DocumentBuilder db = XmlUtils . buildSecureDocumentBuilder ( ) ; final Document d = db . parse ( stream ) ; final XPath xpath = XPathFactory . newInstance ( ) . newXPath ( ) ; final List < NugetPackageRe... | Parses the given stream for MSBuild PackageReference elements . |
11,485 | protected static String getOpenSSLVersion ( long openSSLVersionConstant ) { final long major = openSSLVersionConstant >>> MAJOR_OFFSET ; final long minor = ( openSSLVersionConstant & MINOR_MASK ) >>> MINOR_OFFSET ; final long fix = ( openSSLVersionConstant & FIX_MASK ) >>> FIX_OFFSET ; final long patchLevel = ( openSSL... | Returns the open SSL version as a string . |
11,486 | private String getFileContents ( final File actualFile ) throws AnalysisException { try { return FileUtils . readFileToString ( actualFile , Charset . defaultCharset ( ) ) . trim ( ) ; } catch ( IOException e ) { throw new AnalysisException ( "Problem occurred while reading dependency file." , e ) ; } } | Retrieves the contents of a given file . |
11,487 | public boolean preflightRequest ( ) { final HttpURLConnection conn ; try { final URL url = new URL ( rootURL , "status" ) ; final URLConnectionFactory factory = new URLConnectionFactory ( settings ) ; conn = factory . createHttpURLConnection ( url , useProxy ) ; conn . addRequestProperty ( "Accept" , "application/xml" ... | Do a preflight request to see if the repository is actually working . |
11,488 | private String buildHttpAuthHeaderValue ( ) { final String user = settings . getString ( Settings . KEYS . ANALYZER_NEXUS_USER , "" ) ; final String pass = settings . getString ( Settings . KEYS . ANALYZER_NEXUS_PASSWORD , "" ) ; String result = "" ; if ( user . isEmpty ( ) || pass . isEmpty ( ) ) { LOGGER . debug ( "S... | Constructs the base64 encoded basic authentication header value . |
11,489 | private PackageUrl parsePackageUrl ( final String value ) { try { return PackageUrl . parse ( value ) ; } catch ( PackageUrl . InvalidException e ) { log . warn ( "Invalid Package-URL: {}" , value , e ) ; return null ; } } | Helper to complain if unable to parse Package - URL . |
11,490 | private Map < PackageUrl , ComponentReport > requestReports ( final Dependency [ ] dependencies ) throws Exception { log . debug ( "Requesting component-reports for {} dependencies" , dependencies . length ) ; List < PackageUrl > packages = new ArrayList < > ( ) ; for ( Dependency dependency : dependencies ) { for ( Id... | Batch request component - reports for all dependencies . |
11,491 | private void enrich ( final Dependency dependency ) { log . debug ( "Enrich dependency: {}" , dependency ) ; for ( Identifier id : dependency . getSoftwareIdentifiers ( ) ) { if ( id instanceof PurlIdentifier ) { log . debug ( " Package: {} -> {}" , id , id . getConfidence ( ) ) ; PackageUrl purl = parsePackageUrl ( i... | Attempt to enrich given dependency with vulnerability details from OSS Index component - report . |
11,492 | private void calculateChecksums ( File file ) { try { this . md5sum = Checksum . getMD5Checksum ( file ) ; this . sha1sum = Checksum . getSHA1Checksum ( file ) ; this . sha256sum = Checksum . getSHA256Checksum ( file ) ; } catch ( NoSuchAlgorithmException | IOException ex ) { LOGGER . debug ( String . format ( "Unable ... | Calculates the checksums for the given file . |
11,493 | public void setActualFilePath ( String actualFilePath ) { this . actualFilePath = actualFilePath ; this . sha1sum = null ; this . sha256sum = null ; this . md5sum = null ; final File file = getActualFile ( ) ; if ( file . isFile ( ) ) { calculateChecksums ( this . getActualFile ( ) ) ; } } | Sets the actual file path of the dependency on disk . |
11,494 | public String getDisplayFileName ( ) { if ( displayName != null ) { return displayName ; } if ( ! isVirtual ) { return fileName ; } if ( name == null ) { return fileName ; } if ( version == null ) { return name ; } return name + ":" + version ; } | Returns the file name to display in reports ; if no display file name has been set it will default to constructing a name based on the name and version fields otherwise it will return the actual file name . |
11,495 | public synchronized void addSoftwareIdentifier ( Identifier identifier ) { assert ! ( identifier instanceof CpeIdentifier ) : "vulnerability identifier cannot be added to software identifiers" ; final Optional < Identifier > found = softwareIdentifiers . stream ( ) . filter ( id -> id . getValue ( ) . equals ( identifi... | Adds an entry to the list of detected Identifiers for the dependency file . |
11,496 | public void addAsEvidence ( String source , MavenArtifact mavenArtifact , Confidence confidence ) { if ( mavenArtifact . getGroupId ( ) != null && ! mavenArtifact . getGroupId ( ) . isEmpty ( ) ) { this . addEvidence ( EvidenceType . VENDOR , source , "groupid" , mavenArtifact . getGroupId ( ) , confidence ) ; } if ( m... | Adds the Maven artifact as evidence . |
11,497 | public synchronized Set < Vulnerability > getVulnerabilities ( boolean sorted ) { final Set < Vulnerability > vulnerabilitySet ; if ( sorted ) { vulnerabilitySet = new TreeSet < > ( vulnerabilities ) ; } else { vulnerabilitySet = vulnerabilities ; } return Collections . unmodifiableSet ( vulnerabilitySet ) ; } | Get the unmodifiable list of vulnerabilities ; optionally sorted . |
11,498 | public synchronized Set < Vulnerability > getSuppressedVulnerabilities ( boolean sorted ) { final Set < Vulnerability > vulnerabilitySet ; if ( sorted ) { vulnerabilitySet = new TreeSet < > ( suppressedVulnerabilities ) ; } else { vulnerabilitySet = suppressedVulnerabilities ; } return Collections . unmodifiableSet ( v... | Get an unmodifiable optionally sorted . set of suppressedVulnerabilities . |
11,499 | private String determineHashes ( HashingFunction hashFunction ) { if ( isVirtual ) { return null ; } try { final File file = getActualFile ( ) ; return hashFunction . hash ( file ) ; } catch ( IOException | RuntimeException ex ) { LOGGER . warn ( "Unable to read '{}' to determine hashes." , actualFilePath ) ; LOGGER . ... | Determines the SHA1 and MD5 sum for the given file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.