use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class ProjectFactory method get.
public static Project get() {
final MockSqlProvider provider = new MockSqlProvider();
final Date creationDate = new Date();
final Date modificationDate = new Date();
final CProject internalProject = new CProject(123, "Name", "Comment", creationDate, modificationDate, 55, new FilledList<DebuggerTemplate>(), provider);
final TagManager nodeTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, provider))), TagType.NODE_TAG, provider));
final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
final Database db = new Database(new MockDatabase());
return new Project(db, internalProject, nodeTagManager, viewTagManager);
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLDatabaseFunctions method loadProjects.
/**
* Loads the projects of a database.
*
* @param provider The SQL provider that provides the connection.
* @param debuggerManager Debugger manager object that belongs to the given database.
*
* @return A list of projects that contains the projects stored in the database.
*
* @throws CouldntLoadDataException Thrown if the projects could not be loaded from the database.
*/
public static List<INaviProject> loadProjects(final AbstractSQLProvider provider, final DebuggerTemplateManager debuggerManager) throws CouldntLoadDataException {
PostgreSQLDatabaseFunctions.checkArguments(provider, debuggerManager);
final CConnection connection = provider.getConnection();
final List<INaviProject> projects = new ArrayList<>();
if (!PostgreSQLHelpers.hasTable(connection, CTableNames.PROJECTS_TABLE)) {
return projects;
}
String query = "SELECT id, name, description, creation_date, modification_date, " + " (SELECT count(*) FROM " + CTableNames.ADDRESS_SPACES_TABLE + " WHERE project_id = " + CTableNames.PROJECTS_TABLE + ".id) " + " AS addressspace_count FROM " + CTableNames.PROJECTS_TABLE;
try (ResultSet resultSet = connection.executeQuery(query, true)) {
while (resultSet.next()) {
final int projectId = resultSet.getInt("id");
final String name = PostgreSQLHelpers.readString(resultSet, "name");
final String description = PostgreSQLHelpers.readString(resultSet, "description");
final int addressSpaceCount = resultSet.getInt("addressspace_count");
final Timestamp creationDate = resultSet.getTimestamp("creation_date");
final Timestamp modificationDate = resultSet.getTimestamp("modification_date");
final List<DebuggerTemplate> debuggers = PostgreSQLDatabaseFunctions.getAssignedDebuggers(connection, projectId, debuggerManager);
projects.add(new CProject(projectId, name, description == null ? "" : description, creationDate, modificationDate, addressSpaceCount, debuggers, provider));
}
} catch (final SQLException e) {
throw new CouldntLoadDataException(e);
}
return new ArrayList<INaviProject>(projects);
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLProvider method createProject.
@Override
public CProject createProject(final String name) throws CouldntSaveDataException {
final CProject project = PostgreSQLProjectCreator.createProject(this, name);
projects.add(project);
return project;
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLTypeInstanceFunctionsTests method setUp.
@Before
public void setUp() throws IOException, CouldntLoadDriverException, CouldntConnectException, IllegalStateException, CouldntLoadDataException, InvalidDatabaseException, CouldntInitializeDatabaseException, CouldntSaveDataException, InvalidExporterDatabaseFormatException, InvalidDatabaseVersionException, LoadCancelledException, FileReadException {
final String[] parts = CConfigLoader.loadPostgreSQL();
database = new CDatabase("None", CJdbcDriverNames.jdbcPostgreSQLDriverName, parts[0], "test_disassembly", parts[1], parts[2], parts[3], false, false);
database.connect();
database.load();
try {
final Field privateProviderField = CDatabase.class.getDeclaredField("provider");
privateProviderField.setAccessible(true);
provider = (SQLProvider) privateProviderField.get(database);
} catch (final Exception exception) {
throw new RuntimeException(exception);
}
provider.createDebuggerTemplate("Test Debugger", "localhost", 2222);
final CProject project = provider.createProject("Test Project");
provider.createAddressSpace(project, "Test Address Space");
ConfigManager.instance().read();
module = database.getContent().getModules().get(0);
}
use of com.google.security.zynamics.binnavi.disassembly.CProject in project binnavi by google.
the class PostgreSQLProviderTest method testSetImageBase1.
@Test
public void testSetImageBase1() throws CouldntSaveDataException, CouldntLoadDataException {
final CProject project = getProvider().createProject("SOME_TEST_PROJECT");
getProvider().createAddressSpace(project, "SOME_ADDRESS_SPACE");
final CAddressSpace addressSpace = getProvider().loadAddressSpaces(project).get(0);
final INaviModule module = getProvider().loadModules().get(0);
getProvider().setImageBase(addressSpace, module, new CAddress(BigInteger.valueOf(0)));
}
Aggregations