1#include "gtest/gtest.h"
4#define YARA_RULES "rules.pkg"
5#define EICAR_PATH "eicarcom2.zip"
23 std::vector<string> result = yaraScan->YaraScanFile(
"C:\\Windows\\System32\\notepad.exe");
24 EXPECT_EQ(result.size(), 0);
28 std::vector<string> result = yaraScan->YaraScanFile(
EICAR_PATH);
29 EXPECT_GT(result.size(), 0);
35 for (
int i = 0; i < 3; i++) {
36 EXPECT_THROW(yaraScan->YaraScanFile(
"C:\\does\\not\\exist.exe"), std::runtime_error);
38 EXPECT_EQ(yaraScan->YaraScanFile(
"C:\\Windows\\System32\\notepad.exe").size(), 0);
41 TEST(SignatureTest, NotePadIsTrusted) {
47 EXPECT_FALSE(info.
signer.empty());
50 TEST(SignatureTest, EmbeddedSignatureIsTrusted) {
52 const char* path =
"C:\\Windows\\System32\\MpSigStub.exe";
53 if (GetFileAttributesA(path) == INVALID_FILE_ATTRIBUTES) {
54 GTEST_SKIP() <<
"MpSigStub.exe is not present";
61 EXPECT_FALSE(info.
signer.empty());
64 TEST(SignatureTest, EicarIsUnsigned) {
69 EXPECT_TRUE(info.
signer.empty());
SignatureInfo VerifyFileSignature(const std::string &PathToFile)
Verify the Authenticode signature of a file using WinVerifyTrust. The embedded signature is checked f...
The YaraScanner class that is used to scan a file using YARA rules.
TEST(SignatureTest, NotePadIsTrusted)
TEST_F(YaraScanTest, ScanNotePad)
The result of verifying a file's Authenticode signature with WinVerifyTrust.
bool trusted
True if WinVerifyTrust reported the signature as valid and trusted.
std::string signer
The signing certificate's display name (UTF-8), empty if unsigned.
LONG trustStatus
The WinVerifyTrust result, 0 if trusted.
bool isSigned
True if the file has an embedded or catalog signature.
bool catalogSigned
True if the signature came from a catalog file rather than being embedded.