当前位置: 首页>>代码示例>>Java>>正文


Java VictimsDBInterface类代码示例

本文整理汇总了Java中com.redhat.victims.database.VictimsDBInterface的典型用法代码示例。如果您正苦于以下问题:Java VictimsDBInterface类的具体用法?Java VictimsDBInterface怎么用?Java VictimsDBInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


VictimsDBInterface类属于com.redhat.victims.database包,在下文中一共展示了VictimsDBInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFingerprintVulnerabilities

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * check if storage file is vulnerable via fingerprint
 *
 * @param item storage item
 * @return list of CVEs
 */
public HashSet<String> getFingerprintVulnerabilities(final StorageFileItem item) {

	HashSet<String> cves = new HashSet<String>();

	try {
		VictimsDBInterface db = getVictimsDB();
		for (VictimsRecord vr : VictimsScanner.getRecords(item.getInputStream(), item.getName())) {
			cves = db.getVulnerabilities(vr);
		}
	} catch (Exception ex) {
		log.error(ex.getMessage(), ex);

	}
	return cves;
}
 
开发者ID:skavanagh,项目名称:victims-plugin-nexus,代码行数:22,代码来源:VictimsNexusScanner.java

示例2: getMetadataVulnerabilities

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * check if storage file is vulnerable via meta data
 *
 * @param item storage item
 * @return list of CVEs
 */
public HashSet<String> getMetadataVulnerabilities(final StorageFileItem item) {

	HashSet<String> cves = new HashSet<String>();

	try {
		VictimsDBInterface db = getVictimsDB();
		for (VictimsRecord vr : VictimsScanner.getRecords(item.getInputStream(), item.getName())) {

			for (String key : vr.getMetaData().keySet()) {
				HashSet<String> cveCheck = db.getVulnerabilities(vr.getMetaData().get(key));

				if (!cveCheck.isEmpty()) {
					cves.addAll(cveCheck);
				}
			}
		}

	} catch (Exception ex) {
		log.error(ex.getMessage(), ex);

	}
	return cves;

}
 
开发者ID:skavanagh,项目名称:victims-plugin-nexus,代码行数:31,代码来源:VictimsNexusScanner.java

示例3: testDerby

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
@Test(expected = VictimsException.class)
public void testDerby() throws IOException, VictimsException {
    String old = System.getProperty(VictimsConfig.Key.DB_DRIVER);
    try {
        System.setProperty(VictimsConfig.Key.DB_DRIVER,
                "org.apache.derby.jdbc.EmbeddedDriver");
        VictimsDBInterface vdb = VictimsDB.db();
        vdb.synchronize();
    } finally {
        if (old != null) {
            System.setProperty(VictimsConfig.Key.DB_DRIVER, old);
        } else {
            System.clearProperty(VictimsConfig.Key.DB_DRIVER);
        }
    }

}
 
开发者ID:victims,项目名称:victims-lib-java,代码行数:18,代码来源:VictimsDatabaseTest.java

示例4: getVictimsDB

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * sync and return victims db
 *
 * @return victims db
 */
private VictimsDBInterface getVictimsDB() {
	VictimsDBInterface db = null;
	try {
		db = VictimsDB.db();
		//todo add option and logic to set update interval
		db.synchronize();
	} catch (Exception ex) {
		log.error(ex.getMessage(), ex);
	}
	return db;
}
 
开发者ID:skavanagh,项目名称:victims-plugin-nexus,代码行数:17,代码来源:VictimsNexusScanner.java

示例5: testVulnerabilities

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
private void testVulnerabilities(VictimsDBInterface vdb, boolean embedded, boolean meta)
        throws IOException, VictimsException {
    FileInputStream fin = new FileInputStream(Resources.TEST_RESPONSE);
    RecordStream rs = new RecordStream(fin);
    VictimsRecord vr;
    while (rs.hasNext()) {
        vr = rs.getNext();
        if (vr.getHashes(Algorithms.SHA512).size() > 0) {
            HashSet<String> cves = getVulnerabilities(vdb, vr);
            HashSet<String> result;

            if (meta) {
                result = vdb.getVulnerabilities(vr.getFlattenedMetaData());
            } else {
                vr.hash = "0";
                if (embedded) {
                    // since we are testing for embedded, inject some new
                    // filehashes to simulate a superset
                    vr.getHashes(Algorithms.SHA512).put("1", "1");
                    vr.getHashes(Algorithms.SHA512).put("2", "2");
                }
                result = getVulnerabilities(vdb, vr);
            }
            assertEquals("Unexpected number of CVEs", cves.size(),
                    result.size());
            for (String cve : cves) {
                assertTrue(String.format(
                        "%s was expected, but was not found in result.",
                        cve), result.contains(cve));
            }
            break;
        }
    }
}
 
开发者ID:victims,项目名称:victims-lib-java,代码行数:35,代码来源:VictimsDatabaseTest.java

示例6: testPurgeOnSync

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
@Test
public void testPurgeOnSync() throws VictimsException {
    String hash = "0";
    VictimsResultCache vrc = prepareCache(hash);
    VictimsDBInterface vdb = VictimsDB.db();
    vdb.synchronize();
    assertTrue("Cache was not correctly purged on database sync.",
            !vrc.exists(hash));
}
 
开发者ID:victims,项目名称:victims-lib-java,代码行数:10,代码来源:VictimsResultCacheTest.java

示例7: execute

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
@Override
public CommandResult execute(List<String> args) {
    try { 
        VictimsDBInterface db = VictimsDB.db();
        db.synchronize();
        ExitSuccess result = new ExitSuccess(null);
        result.addVerboseOutput("synchronization complete!");
        return result;
                
    } catch (VictimsException e){
        //e.printStackTrace();
        return new ExitFailure(e.getMessage());
    }
}
 
开发者ID:victims,项目名称:victims-client-java-legacy,代码行数:15,代码来源:SynchronizeCommand.java

示例8: execute

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
@Override
public CommandResult execute(List<String> args) {
      try {

        VictimsDBInterface db = Environment.getInstance().getDatabase();
        return new ExitSuccess("Database last updated on: " + db.lastUpdated().toString());
                
    } catch (VictimsException e){
        //e.printStackTrace();
        return new ExitFailure(e.getMessage());
    }
}
 
开发者ID:victims,项目名称:victims-client-java-legacy,代码行数:13,代码来源:LastUpdateCommand.java

示例9: updateDatabase

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * Updates the database according to the given configuration
 * 
 * @param ctx
 * @throws VictimsException
 */
public void updateDatabase(ExecutionContext ctx) throws VictimsException {

	VictimsDBInterface db = ctx.getDatabase();
	LogOutputResource log = ctx.getLog();

	Date updated = db.lastUpdated();

	// update automatically every time
	if (ctx.updateAlways()) {
		log.log(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(),
				VictimsConfig.uri()), LogLevel.INFO.getLevel());
		db.synchronize();

		// update once per day
	} else if (ctx.updateDaily()) {

		Date today = new Date();
		SimpleDateFormat cmp = new SimpleDateFormat("yyyMMdd");
		boolean updatedToday = cmp.format(today)
				.equals(cmp.format(updated));

		if (!updatedToday) {
			log.log(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(),
					VictimsConfig.uri()), LogLevel.INFO.getLevel());
			db.synchronize();

		} else {
			log.log("Database last synchronized: " + updated.toString(),
					LogLevel.DEBUG.getLevel());
		}

		// updates disabled
	} else {
		log.log("Database synchronization disabled.",
				LogLevel.INFO.getLevel());
	}

}
 
开发者ID:victims,项目名称:victims-plugin-ant-legacy,代码行数:45,代码来源:VictimsTask.java

示例10: setupExecutionContext

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
private void setupExecutionContext(PrintStream log) throws AbortException {
    ctx = new ExecutionContext();
    ctx.setSettings(new Settings());
    ctx.setLog(log);

    ctx.getSettings().set(VictimsConfig.Key.URI, baseUrl);
    ctx.getSettings().set(VictimsConfig.Key.DB_DRIVER, jdbcDriver);
    ctx.getSettings().set(VictimsConfig.Key.DB_URL, jdbcUrl);
    ctx.getSettings().set(Settings.METADATA, metadata);
    ctx.getSettings().set(Settings.FINGERPRINT, fingerprint);
    ctx.getSettings().set(VictimsConfig.Key.ENTRY, entryPoint);
    ctx.getSettings().set(VictimsConfig.Key.DB_USER, jdbcUsername);
    ctx.getSettings().set(VictimsConfig.Key.DB_PASS, jdbcPassword);
    ctx.getSettings().set(Settings.UPDATE_DATABASE, updates);

    System.setProperty(VictimsConfig.Key.ALGORITHMS, "SHA512");

    try {
        VictimsResultCache cache = new VictimsResultCache();
        ctx.setCache(cache);

        VictimsDBInterface db = VictimsDB.db();
        ctx.setDatabase(db);

        ctx.getSettings().validate();
        ctx.getSettings().show(ctx.getLog());
    } catch (VictimsException e) {
        log.println("[VICTIMS] ERROR:");
        log.println(e.getMessage());
        throw new AbortException();
    }
}
 
开发者ID:victims,项目名称:victims-plugin-jenkins-legacy,代码行数:33,代码来源:VictimsPostBuildScanner.java

示例11: updateDatabase

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * Updates the database according to the given configuration
 * 
 * @param ctx
 * @throws VictimsException
 */
private void updateDatabase(ExecutionContext context)
        throws VictimsException {
    VictimsDBInterface db = context.getDatabase();
    PrintStream log = context.getLog();

    Date updated = db.lastUpdated();

    // update: auto
    if (context.updateAlways()) {
        log.println("Updating database");
        db.synchronize();
    } else if (context.updateDaily()) { // update: daily
        Date today = new Date();
        SimpleDateFormat cmp = new SimpleDateFormat("yyyyMMdd");
        boolean updatedToday = cmp.format(today)
                .equals(cmp.format(updated));

        if (!updatedToday) {
            log.println("Updating database");
            db.synchronize();
        } else {
            log.println("Database last updated: "
                    + updated.toString());
        }
    } else { // update: disabled
        log.println("Database synchronization disabled.");
    }
}
 
开发者ID:victims,项目名称:victims-plugin-jenkins-legacy,代码行数:35,代码来源:VictimsPostBuildScanner.java

示例12: getVulnerabilities

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
private HashSet<String> getVulnerabilities(VictimsDBInterface vdb,
        VictimsRecord vr) throws VictimsException {
    return vdb.getVulnerabilities(vr);
}
 
开发者ID:victims,项目名称:victims-lib-java,代码行数:5,代码来源:VictimsDatabaseTest.java

示例13: testResync

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
@Test
public void testResync() throws VictimsException {
    VictimsDBInterface vdb = VictimsDB.db();
    vdb.synchronize();
}
 
开发者ID:victims,项目名称:victims-lib-java,代码行数:6,代码来源:VictimsDatabaseTest.java

示例14: getDatabase

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * @return victims DB
 */
public VictimsDBInterface getDatabase() {
	return database;
}
 
开发者ID:victims,项目名称:victims-plugin-eclipse-legacy,代码行数:7,代码来源:ExecutionContext.java

示例15: VictimScan

import com.redhat.victims.database.VictimsDBInterface; //导入依赖的package包/类
/**
 * Initialises the scan.
 * 
 * @param set
 *            Victims settings map
 * @param paths
 *            Absolute paths to projects dependencies
 * @throws VictimsException
 */
public VictimScan(Map<String, String> set, ArrayList<IPath> paths)
		throws VictimsException {
	this.paths = paths;

	/* Set up context */
	ctx = new ExecutionContext();
	ctx.setSettings(new Settings());
	log = ctx.getLog();
	Driver driver = new Driver();
	/* Apply user supplied/default settings from option menu */
	Settings settings = ctx.getSettings();
	settings.set(VictimsConfig.Key.URI, set.get(VictimsConfig.Key.URI));
	System.setProperty(VictimsConfig.Key.URI,
			set.get(VictimsConfig.Key.URI));
	settings.set(VictimsConfig.Key.DB_DRIVER,
			set.get(VictimsConfig.Key.DB_DRIVER));
	System.setProperty(VictimsConfig.Key.DB_DRIVER,
			set.get(VictimsConfig.Key.DB_DRIVER));
	settings.set(VictimsConfig.Key.DB_URL,
			set.get(VictimsConfig.Key.DB_URL));
	System.setProperty(VictimsConfig.Key.DB_URL,
			set.get(VictimsConfig.Key.DB_URL));
	settings.set(VictimsConfig.Key.ENTRY, set.get(VictimsConfig.Key.ENTRY));
	System.setProperty(VictimsConfig.Key.ENTRY,
			set.get(VictimsConfig.Key.ENTRY));
	settings.set(VictimsConfig.Key.DB_USER,
			set.get(VictimsConfig.Key.DB_USER));
	System.setProperty(VictimsConfig.Key.DB_USER,
			set.get(VictimsConfig.Key.DB_USER));
	settings.set(VictimsConfig.Key.DB_PASS, "(not shown)");
	System.setProperty(VictimsConfig.Key.DB_PASS,
			set.get(VictimsConfig.Key.DB_PASS));
	settings.set(Settings.METADATA, set.get(Settings.METADATA));
	settings.set(Settings.FINGERPRINT, set.get(Settings.FINGERPRINT));
	settings.set(Settings.UPDATE_DATABASE,
			set.get(Settings.UPDATE_DATABASE));

	// Only use 1 algorithm for comparisons
	System.setProperty(VictimsConfig.Key.ALGORITHMS, "SHA512");

	/* Create results cache & victims DB */
	VictimsResultCache cache = new VictimsResultCache();
	ctx.setCache(cache);
	driver.getClass();
	VictimsDBInterface db = VictimsDB.db();
	ctx.setDatabase(db);

	// validate
	ctx.getSettings().validate();
	ctx.getSettings().show(ctx.getLog());

}
 
开发者ID:victims,项目名称:victims-plugin-eclipse-legacy,代码行数:62,代码来源:VictimScan.java


注:本文中的com.redhat.victims.database.VictimsDBInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。