Skip to content

Commit 18a25c5

Browse files
committed
C++: Add tests with missing flow sources.
1 parent cd7bb54 commit 18a25c5

File tree

1 file changed

+177
-0
lines changed
  • cpp/ql/test/library-tests/dataflow/external-models

1 file changed

+177
-0
lines changed

cpp/ql/test/library-tests/dataflow/external-models/windows.cpp

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,4 +734,181 @@ void test_winhttp_crack_url() {
734734
sink(urlComponents.lpszExtraInfo);
735735
sink(*urlComponents.lpszExtraInfo); // $ ir
736736
}
737+
}
738+
739+
using HTTP_REQUEST_ID = ULONGLONG;
740+
using HTTP_CONNECTION_ID = ULONGLONG;
741+
using HTTP_URL_CONTEXT = ULONGLONG;
742+
using HTTP_RAW_CONNECTION_ID = ULONGLONG;
743+
744+
typedef struct _HTTP_VERSION {
745+
USHORT MajorVersion;
746+
USHORT MinorVersion;
747+
} HTTP_VERSION, *PHTTP_VERSION;
748+
749+
typedef enum _HTTP_VERB {
750+
HttpVerbUnparsed = 0
751+
} HTTP_VERB, *PHTTP_VERB;
752+
753+
typedef struct _HTTP_COOKED_URL {
754+
USHORT FullUrlLength;
755+
USHORT HostLength;
756+
USHORT AbsPathLength;
757+
USHORT QueryStringLength;
758+
PCWSTR pFullUrl;
759+
PCWSTR pHost;
760+
PCWSTR pAbsPath;
761+
PCWSTR pQueryString;
762+
} HTTP_COOKED_URL, *PHTTP_COOKED_URL;
763+
764+
typedef struct _HTTP_TRANSPORT_ADDRESS {
765+
struct sockaddr* pRemoteAddress;
766+
struct sockaddr* pLocalAddress;
767+
} HTTP_TRANSPORT_ADDRESS, *PHTTP_TRANSPORT_ADDRESS;
768+
769+
typedef struct _HTTP_KNOWN_HEADER {
770+
USHORT RawValueLength;
771+
PCSTR pRawValue;
772+
} HTTP_KNOWN_HEADER, *PHTTP_KNOWN_HEADER;
773+
774+
typedef struct _HTTP_UNKNOWN_HEADER {
775+
USHORT NameLength;
776+
USHORT RawValueLength;
777+
PCSTR pName;
778+
PCSTR pRawValue;
779+
} HTTP_UNKNOWN_HEADER, *PHTTP_UNKNOWN_HEADER;
780+
781+
typedef struct _HTTP_REQUEST_HEADERS {
782+
USHORT UnknownHeaderCount;
783+
PHTTP_UNKNOWN_HEADER pUnknownHeaders;
784+
USHORT TrailerCount;
785+
PHTTP_UNKNOWN_HEADER pTrailers;
786+
HTTP_KNOWN_HEADER KnownHeaders[41];
787+
} HTTP_REQUEST_HEADERS, *PHTTP_REQUEST_HEADERS;
788+
789+
typedef struct _HTTP_BYTE_RANGE {
790+
ULONGLONG StartingOffset;
791+
ULONGLONG Length;
792+
} HTTP_BYTE_RANGE, *PHTTP_BYTE_RANGE;
793+
794+
typedef struct _HTTP_DATA_CHUNK {
795+
int DataChunkType;
796+
union {
797+
struct {
798+
PVOID pBuffer;
799+
ULONG BufferLength;
800+
} FromMemory;
801+
struct {
802+
HTTP_BYTE_RANGE ByteRange;
803+
HANDLE FileHandle;
804+
} FromFileHandle;
805+
struct {
806+
USHORT FragmentNameLength;
807+
PCWSTR pFragmentName;
808+
} FromFragmentCache;
809+
struct {
810+
HTTP_BYTE_RANGE ByteRange;
811+
PCWSTR pFragmentName;
812+
} FromFragmentCacheEx;
813+
struct {
814+
USHORT TrailerCount;
815+
PHTTP_UNKNOWN_HEADER pTrailers;
816+
} Trailers;
817+
};
818+
} HTTP_DATA_CHUNK, *PHTTP_DATA_CHUNK;
819+
820+
typedef struct _HTTP_SSL_CLIENT_CERT_INFO {
821+
ULONG CertFlags;
822+
ULONG CertEncodedSize;
823+
char* pCertEncoded;
824+
HANDLE Token;
825+
BOOL CertDeniedByMapper;
826+
} HTTP_SSL_CLIENT_CERT_INFO, *PHTTP_SSL_CLIENT_CERT_INFO;
827+
828+
typedef struct _HTTP_SSL_INFO {
829+
USHORT ServerCertKeySize;
830+
USHORT ConnectionKeySize;
831+
ULONG ServerCertIssuerSize;
832+
ULONG ServerCertSubjectSize;
833+
PCSTR pServerCertIssuer;
834+
PCSTR pServerCertSubject;
835+
PHTTP_SSL_CLIENT_CERT_INFO pClientCertInfo;
836+
ULONG SslClientCertNegotiated;
837+
} HTTP_SSL_INFO, *PHTTP_SSL_INFO;
838+
839+
typedef struct _HTTP_REQUEST {
840+
ULONG Flags;
841+
HTTP_CONNECTION_ID ConnectionId;
842+
HTTP_REQUEST_ID RequestId;
843+
HTTP_URL_CONTEXT UrlContext;
844+
HTTP_VERSION Version;
845+
HTTP_VERB Verb;
846+
USHORT UnknownVerbLength;
847+
USHORT RawUrlLength;
848+
PCSTR pUnknownVerb;
849+
PCSTR pRawUrl;
850+
HTTP_COOKED_URL CookedUrl;
851+
HTTP_TRANSPORT_ADDRESS Address;
852+
HTTP_REQUEST_HEADERS Headers;
853+
ULONGLONG BytesReceived;
854+
USHORT EntityChunkCount;
855+
PHTTP_DATA_CHUNK pEntityChunks;
856+
HTTP_RAW_CONNECTION_ID RawConnectionId;
857+
PHTTP_SSL_INFO pSslInfo;
858+
} HTTP_REQUEST, *PHTTP_REQUEST;
859+
860+
ULONG HttpReceiveHttpRequest(
861+
HANDLE RequestQueueHandle,
862+
HTTP_REQUEST_ID RequestId,
863+
ULONG Flags,
864+
PHTTP_REQUEST RequestBuffer,
865+
ULONG RequestBufferLength,
866+
PULONG BytesReturned,
867+
LPOVERLAPPED Overlapped
868+
);
869+
870+
ULONG HttpReceiveRequestEntityBody(
871+
HANDLE RequestQueueHandle,
872+
HTTP_REQUEST_ID RequestId,
873+
ULONG Flags,
874+
PVOID EntityBuffer,
875+
ULONG EntityBufferLength,
876+
PULONG BytesReturned,
877+
LPOVERLAPPED Overlapped
878+
);
879+
880+
ULONG HttpReceiveClientCertificate(
881+
HANDLE RequestQueueHandle,
882+
HTTP_CONNECTION_ID ConnectionId,
883+
ULONG Flags,
884+
PHTTP_SSL_CLIENT_CERT_INFO SslClientCertInfo,
885+
ULONG SslClientCertInfoSize,
886+
PULONG BytesReceived,
887+
LPOVERLAPPED Overlapped
888+
);
889+
890+
void test_http_server_api(HANDLE hRequestQueue) {
891+
{
892+
HTTP_REQUEST requestBuffer;
893+
ULONG bytesReturned;
894+
ULONG result = HttpReceiveHttpRequest(hRequestQueue, 0, 0, &requestBuffer, sizeof(requestBuffer), &bytesReturned, nullptr);
895+
char* p = reinterpret_cast<char*>(&requestBuffer);
896+
sink(p);
897+
sink(*p); // $ MISSING: ir
898+
}
899+
{
900+
char buffer[1024];
901+
ULONG bytesReturned;
902+
ULONG result = HttpReceiveRequestEntityBody(hRequestQueue, 0, 0, buffer, sizeof(buffer), &bytesReturned, nullptr);
903+
sink(buffer);
904+
sink(*buffer); // $ MISSING: ir
905+
}
906+
{
907+
HTTP_SSL_CLIENT_CERT_INFO certInfo;
908+
ULONG bytesReceived;
909+
ULONG result = HttpReceiveClientCertificate(hRequestQueue, 0, 0, &certInfo, sizeof(certInfo), &bytesReceived, nullptr);
910+
char* p = reinterpret_cast<char*>(&certInfo);
911+
sink(p);
912+
sink(*p); // $ MISSING: ir
913+
}
737914
}

0 commit comments

Comments
 (0)