chore: migrate project into clean repository

This commit is contained in:
yuuux
2026-08-13 16:50:52 +08:00
commit d1d25a09e7
27405 changed files with 9422808 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
CBMC proof include files
========================
This directory contains include files written for CBMC proof. It is
common to write some code to model aspects of the system under test,
and the header files for this code go here.

View File

@@ -0,0 +1,53 @@
/*
* coreHTTP v2.1.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file callback_stubs.h
* @brief Defines a stub function for
* #HTTPClient_ResponseHeaderParsingCallback_t.onHeaderCallback
*/
#ifndef CALLBACK_STUBS_H_
#define CALLBACK_STUBS_H_
#include <string.h>
#include <stdint.h>
/**
* @brief Invoked when both a header field and its associated header value are found.
*
* @param[in] pContext User context.
* @param[in] fieldLoc Location of the header field name in the response buffer.
* @param[in] fieldLen Length in bytes of the field name.
* @param[in] valueLoc Location of the header value in the response buffer.
* @param[in] valueLen Length in bytes of the value.
* @param[in] statusCode The HTTP response status-code.
*/
void onHeaderCallbackStub( void * pContext,
const char * fieldLoc,
size_t fieldLen,
const char * valueLoc,
size_t valueLen,
uint16_t statusCode );
#endif /* ifndef CALLBACK_STUBS_H_ */

View File

@@ -0,0 +1,67 @@
/*
* coreHTTP v2.1.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file core_http_config.h
* @brief Custom configurations for the coreHTTP library.
*/
#ifndef CORE_HTTP_CONFIG_H
#define CORE_HTTP_CONFIG_H
/**
* @brief The maximum duration between non-empty network reads while receiving
* an HTTP response via the #HTTPClient_Send API function.
*
* The transport receive function may be called multiple times until the end of
* the response is detected by the parser. This timeout represents the maximum
* duration that is allowed without any data reception from the network for the
* incoming response.
*
* If the timeout expires, the #HTTPClient_Send function will return
* #HTTPNetworkError.
*
* This is set to 1 to exit right away after a zero is received in the transport
* receive stub. There is no added value, in proving memory safety, to repeat
* the logic that checks if the retry timeout is reached.
*/
#define HTTP_RECV_RETRY_TIMEOUT_MS ( 1U )
/**
* @brief The maximum duration between non-empty network transmissions while
* sending an HTTP request via the #HTTPClient_Send API function.
*
* When sending an HTTP request, the transport send function may be called multiple
* times until all of the required number of bytes are sent.
* This timeout represents the maximum duration that is allowed for no data
* transmission over the network through the transport send function.
*
* If the timeout expires, the #HTTPClient_Send function returns #HTTPNetworkError.
*
* This is set to 1 to exit right away after a zero is received in the transport
* send stub. There is no added value, in proving memory safety, to repeat
* the logic that checks if the retry timeout is reached.
*/
#define HTTP_SEND_RETRY_TIMEOUT_MS ( 1U )
#endif /* ifndef CORE_HTTP_CONFIG_H */

View File

@@ -0,0 +1,38 @@
/*
* coreHTTP v2.1.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file get_time_stub.h
* @brief Stub definition for the application defined callback to retrieve the
* current time in milliseconds.
*/
#ifndef GET_TIME_STUB_H_
#define GET_TIME_STUB_H_
/**
* Application defined callback to retrieve the current time in milliseconds.
*
* @return The current time in milliseconds.
*/
uint32_t GetCurrentTimeStub( void );
#endif /* ifndef GET_TIME_STUB_H_ */

View File

@@ -0,0 +1,182 @@
/*
* coreHTTP v2.1.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file http_cbmc_state.h
* @brief Functions to allocate memory and validate data types for proofs.
*/
#ifndef HTTP_CBMC_STATE_H_
#define HTTP_CBMC_STATE_H_
#include <stdbool.h>
#include <stdint.h>
#include "core_http_client.h"
#include "core_http_client_private.h"
#include "http_parser.h"
#include "transport_interface_stubs.h"
struct NetworkContext
{
int filler;
};
/**
* @brief Attains coverage when a variable needs to possibly contain two values.
*/
bool nondet_bool();
/**
* @brief Calls malloc based on given size or returns NULL for coverage.
*
* Implementation of safe malloc which returns NULL if the requested size is 0.
* The behavior of malloc(0) is platform dependent.
* It is possible for malloc(0) to return an address without allocating memory.
*
* @param[in] size Requested size to malloc.
*
* @return Requested memory or NULL.
*/
void * mallocCanFail( size_t size );
/**
* @brief Allocates an #HTTPRequestHeaders_t object.
*
* @param[in] pRequestHeaders #HTTPRequestHeaders_t object to allocate.
*
* @return NULL or pointer to allocated #HTTPRequestHeaders_t object.
*/
HTTPRequestHeaders_t * allocateHttpRequestHeaders( HTTPRequestHeaders_t * pRequestHeaders );
/**
* @brief Validates if a #HTTPRequestHeaders_t object is feasible.
*
* @param[in] pRequestHeaders #HTTPRequestHeaders_t object to validate.
*
* @return True if #pRequestHeaders is feasible; false otherwise.
*/
bool isValidHttpRequestHeaders( const HTTPRequestHeaders_t * pRequestHeaders );
/**
* @brief Allocates a #HTTPRequestInfo_t object.
*
* @param[in] pRequestInfo #HTTPRequestInfo_t object to allocate.
*
* @return NULL or pointer to allocated #HTTPRequestInfo_t object.
*/
HTTPRequestInfo_t * allocateHttpRequestInfo( HTTPRequestInfo_t * pRequestInfo );
/**
* @brief Validates if a #HTTPRequestInfo_t object is feasible.
*
* @param[in] pRequestInfo #HTTPRequestInfo_t object to validate.
*
* @return True if #pRequestInfo is feasible; false otherwise.
*/
bool isValidHttpRequestInfo( const HTTPRequestInfo_t * pRequestInfo );
/**
* @brief Allocates a #HTTPResponse_t object.
*
* @param[in] pResponse #HTTPResponse_t object to allocate.
*
* @return NULL or pointer to allocated #HTTPResponse_t object.
*/
HTTPResponse_t * allocateHttpResponse( HTTPResponse_t * pResponse );
/**
* @brief Validates if a #HTTPResponse_t object is feasible.
*
* @param[in] pResponse #HTTPResponse_t object to validate.
*
* @return True if #HTTPResponse_t is feasible; false otherwise.
*/
bool isValidHttpResponse( const HTTPResponse_t * pResponse );
/**
* @brief Allocates a #TransportInterface_t object.
*
* @param[in] pTransport #TransportInterface_t object to allocate.
*
* @return NULL or pointer to allocated #TransportInterface_t object.
*/
TransportInterface_t * allocateTransportInterface( TransportInterface_t * pTransport );
/**
* @brief Validates if a #TransportInterface_t object is feasible.
*
* @param[in] pTransportInterface #TransportInterface_t object to validate.
*
* @return True if #pTransportInterface is feasible; false otherwise.
*/
bool isValidTransportInterface( TransportInterface_t * pTransportInterface );
/**
* @brief Allocate an #http_parser object that is valid in the context of the
* HTTPClient_Send() function.
*
* @param[in] pHttpParser #http_parser object to allocate.
*
* @return NULL or pointer to allocated #http_parser object.
*/
http_parser * allocateHttpSendParser( http_parser * pHttpParser );
/**
* @brief Allocate an #HTTPParsingContext_t object.
*
* @param[in] pHttpParsingContext #HTTPParsingContext_t object to allocate.
*
* @return NULL or pointer to allocated #HTTPParsingContext_t object.
*/
HTTPParsingContext_t * allocateHttpSendParsingContext( HTTPParsingContext_t * pHttpParsingContext );
/**
* @brief Validates if a #HTTPParsingContext_t object is feasible.
*
* @param[in] pHttpParsingContext #HTTPParsingContext_t object to validate.
*
* @return True if #pHttpParsingContext is feasible; false otherwise.
*/
bool isValidHttpSendParsingContext( const HTTPParsingContext_t * pHttpParsingContext );
/**
* @brief Allocate an #http_parser object that is valid in the context of the
* HTTPClient_ReadHeader() function.
*
* @param[in] pHttpParser #http_parser object to allocate.
*
* @return NULL or pointer to allocated #http_parser object.
*/
http_parser * allocateHttpReadHeaderParser( http_parser * pHttpParser );
/**
* @brief Allocate an #findHeaderContext_t object.
*
* @param[in] pFindHeaderContext #findHeaderContext_t object to allocate.
*
* @return NULL or pointer to allocated #findHeaderContext_t object.
*/
findHeaderContext_t * allocateFindHeaderContext( findHeaderContext_t * pFindHeaderContext );
#endif /* ifndef HTTP_CBMC_STATE_H_ */

View File

@@ -0,0 +1,66 @@
/*
* coreHTTP v2.1.0
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file transport_interface_stubs.h
* @brief Functions, for CBMC proofs, to mock transport sending and receiving
* implementations.
*/
#ifndef TRANSPORT_INTERFACE_STUBS_H_
#define TRANSPORT_INTERFACE_STUBS_H_
#include <stdint.h>
#include "core_http_client.h"
#ifndef MAX_TRIES
#define MAX_TRIES 5
#endif
/**
* @brief Transport interface stub for mocking data sent over the network.
*
* @param[in] pNetworkContext Implementation-defined network context.
* @param[in] pBuffer Buffer containing the bytes to send over the network stack.
* @param[in] bytesToSend Number of bytes to send over the network.
*
* @return The number of bytes sent or a negative error code.
*/
int32_t TransportInterfaceSendStub( NetworkContext_t * pNetworkContext,
void * pBuffer,
size_t bytesToSend );
/**
* @brief Transport interface for mocking data received over the network.
*
* @param[in] pNetworkContext Implementation-defined network context.
* @param[in] pBuffer Buffer to receive the data into.
* @param[in] bytesToRecv Number of bytes requested from the network.
*
* @return The number of bytes received or a negative error code.
*/
int32_t TransportInterfaceReceiveStub( NetworkContext_t * pNetworkContext,
void * pBuffer,
size_t bytesToRecv );
#endif /* ifndef TRANSPORT_INTERFACE_STUBS_H_ */