Skip to content

Commit 96c56a4

Browse files
committed
Required API changes for Enterprise find files.
1 parent 3f39c3f commit 96c56a4

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

binaryninjaapi.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21603,6 +21603,16 @@ namespace BinaryNinja::Collaboration
2160321603
*/
2160421604
std::vector<std::pair<std::string, std::string>> SearchUsers(const std::string& prefix);
2160521605

21606+
struct FileSearchMatch
21607+
{
21608+
std::string projectId;
21609+
std::string projectName;
21610+
std::string fileId;
21611+
std::string fileName;
21612+
};
21613+
21614+
std::vector<FileSearchMatch> FindFiles(const std::string& name);
21615+
2160621616

2160721617
/*!
2160821618
Pull list of users from the remote. Necessary before calling GetUsers()
@@ -22487,4 +22497,3 @@ template<> struct fmt::formatter<BinaryNinja::Type>
2248722497
return it;
2248822498
}
2248922499
};
22490-

binaryninjacore.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Current ABI version for linking to the core. This is incremented any time
3838
// there are changes to the API that affect linking, including new functions,
3939
// new types, or modifications to existing functions or types.
40-
#define BN_CURRENT_CORE_ABI_VERSION 136
40+
#define BN_CURRENT_CORE_ABI_VERSION 137
4141

4242
// Minimum ABI version that is supported for loading of plugins. Plugins that
4343
// are linked to an ABI version less than this will not be able to load and
@@ -312,6 +312,14 @@ extern "C"
312312
typedef struct BNIndirectBranchInfo BNIndirectBranchInfo;
313313
typedef struct BNArchitectureAndAddress BNArchitectureAndAddress;
314314

315+
typedef struct BNRemoteFileSearchMatch
316+
{
317+
char* projectId;
318+
char* projectName;
319+
char* fileId;
320+
char* fileName;
321+
} BNRemoteFileSearchMatch;
322+
315323
typedef bool(*BNProgressFunction)(void*, size_t, size_t);
316324

317325
//! Console log levels
@@ -8240,6 +8248,8 @@ extern "C"
82408248
BINARYNINJACOREAPI BNCollaborationUser* BNRemoteGetUserByUsername(BNRemote* remote, const char* username);
82418249
BINARYNINJACOREAPI BNCollaborationUser* BNRemoteGetCurrentUser(BNRemote* remote);
82428250
BINARYNINJACOREAPI bool BNRemoteSearchUsers(BNRemote* remote, const char* prefix, char*** userIds, char*** usernames, size_t* count);
8251+
BINARYNINJACOREAPI BNRemoteFileSearchMatch* BNRemoteFindFiles(BNRemote* remote, const char* name, size_t* count);
8252+
BINARYNINJACOREAPI void BNFreeRemoteFileSearchMatchList(BNRemoteFileSearchMatch* matches, size_t count);
82438253
BINARYNINJACOREAPI bool BNRemotePullUsers(BNRemote* remote, BNProgressFunction progress, void* progressContext);
82448254
BINARYNINJACOREAPI BNCollaborationUser* BNRemoteCreateUser(BNRemote* remote, const char* username, const char* email, bool isActive, const char* password, const uint64_t* groupIds, size_t groupIdCount, const uint64_t* userPermissionIds, size_t userPermissionIdCount);
82458255
BINARYNINJACOREAPI bool BNRemotePushUser(BNRemote* remote, BNCollaborationUser* user, const char** extraFieldKeys, const char** extraFieldValues, size_t extraFieldCount);

collaboration.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,34 @@ std::vector<std::pair<std::string, std::string>> Remote::SearchUsers(const std::
977977
}
978978

979979

980+
std::vector<Remote::FileSearchMatch> Remote::FindFiles(const std::string& name)
981+
{
982+
size_t count = 0;
983+
BNRemoteFileSearchMatch* matches = BNRemoteFindFiles(m_object, name.c_str(), &count);
984+
std::vector<FileSearchMatch> results;
985+
if (!matches)
986+
return results;
987+
988+
results.reserve(count);
989+
for (size_t i = 0; i < count; i++)
990+
{
991+
FileSearchMatch match;
992+
if (matches[i].projectId)
993+
match.projectId = matches[i].projectId;
994+
if (matches[i].projectName)
995+
match.projectName = matches[i].projectName;
996+
if (matches[i].fileId)
997+
match.fileId = matches[i].fileId;
998+
if (matches[i].fileName)
999+
match.fileName = matches[i].fileName;
1000+
results.push_back(std::move(match));
1001+
}
1002+
1003+
BNFreeRemoteFileSearchMatchList(matches, count);
1004+
return results;
1005+
}
1006+
1007+
9801008
void Remote::PullUsers(ProgressFunction progress)
9811009
{
9821010
ProgressContext pctxt;
@@ -2677,4 +2705,3 @@ CollabUndoEntry::CollabUndoEntry(BNCollaborationUndoEntry* entry)
26772705
{
26782706
m_object = entry;
26792707
}
2680-

0 commit comments

Comments
 (0)