KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_wx_filename.cpp File Reference

Test suite for WX_FILNAME. More...

#include <boost/test/tools/old/interface.hpp>
#include <qa_utils/wx_utils/unit_test_utils.h>
#include <wx_filename.h>
#include <wx/arrstr.h>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Classes

struct  WX_FILENAME_SPLIT_CASE
 Declare the test suite. More...
 

Functions

 BOOST_AUTO_TEST_CASE (Split)
 Check the various split cases work correctly.
 
 BOOST_AUTO_TEST_CASE (SplitArchiveEntryName_RejectsTraversal)
 
 BOOST_AUTO_TEST_CASE (SplitArchiveEntryName_AcceptsRelativeNames)
 
 BOOST_AUTO_TEST_CASE (ResolveArchiveEntryPath_RejectsTraversal)
 
 BOOST_AUTO_TEST_CASE (ResolveArchiveEntryPath_StaysBelowDestination)
 
 BOOST_AUTO_TEST_CASE (IsSafeChildPath_RejectsTraversal)
 
 BOOST_AUTO_TEST_CASE (IsSafeChildPath_AcceptsSingleComponentNames)
 

Variables

static const std::vector< WX_FILENAME_SPLIT_CASEsplit_cases
 
static const std::vector< wxString > hostile_entry_names
 
static const std::vector< std::pair< wxString, wxString > > benign_entry_names
 

Detailed Description

Test suite for WX_FILNAME.

Definition in file test_wx_filename.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/7]

BOOST_AUTO_TEST_CASE ( IsSafeChildPath_AcceptsSingleComponentNames )

Definition at line 265 of file test_wx_filename.cpp.

References BOOST_TEST_CONTEXT(), WX_FILENAME::IsSafeChildPath(), and name.

◆ BOOST_AUTO_TEST_CASE() [2/7]

BOOST_AUTO_TEST_CASE ( IsSafeChildPath_RejectsTraversal )

◆ BOOST_AUTO_TEST_CASE() [3/7]

BOOST_AUTO_TEST_CASE ( ResolveArchiveEntryPath_RejectsTraversal )

◆ BOOST_AUTO_TEST_CASE() [4/7]

BOOST_AUTO_TEST_CASE ( ResolveArchiveEntryPath_StaysBelowDestination )

◆ BOOST_AUTO_TEST_CASE() [5/7]

BOOST_AUTO_TEST_CASE ( Split )

◆ BOOST_AUTO_TEST_CASE() [6/7]

BOOST_AUTO_TEST_CASE ( SplitArchiveEntryName_AcceptsRelativeNames )

◆ BOOST_AUTO_TEST_CASE() [7/7]

BOOST_AUTO_TEST_CASE ( SplitArchiveEntryName_RejectsTraversal )

Variable Documentation

◆ benign_entry_names

const std::vector<std::pair<wxString, wxString> > benign_entry_names
static
Initial value:
= {
{ wxT( "board.kicad_pcb" ), wxT( "board.kicad_pcb" ) },
{ wxT( "./board.kicad_pcb" ), wxT( "board.kicad_pcb" ) },
{ wxT( "sub/board.kicad_pcb" ), wxT( "sub/board.kicad_pcb" ) },
{ wxT( "sub//board.kicad_pcb" ), wxT( "sub/board.kicad_pcb" ) },
{ wxT( "sub/./deep/board.kicad_pcb" ), wxT( "sub/deep/board.kicad_pcb" ) },
{ wxT( "a..b/c.kicad_sch" ), wxT( "a..b/c.kicad_sch" ) },
{ wxT( "...leading/x.txt" ), wxT( "...leading/x.txt" ) },
}

Definition at line 153 of file test_wx_filename.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ hostile_entry_names

const std::vector<wxString> hostile_entry_names
static
Initial value:
= {
wxT( "../evil" ),
wxT( "a/../../evil" ),
wxT( "plugins/../../../../tmp/PCM_PWNED" ),
wxT( "../../../../tmp/PWNED" ),
wxT( "a/b/../../../evil" ),
wxT( ".." ),
wxT( "/etc/passwd" ),
wxT( "//etc/passwd" ),
wxT( "C:/evil" ),
wxT( "C:evil" ),
wxT( "..\\evil" ),
wxT( "plugins\\..\\..\\..\\tmp\\PCM_PWNED" ),
wxT( "\\\\server\\share\\evil" ),
wxT( "" ),
}

Definition at line 134 of file test_wx_filename.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ split_cases

const std::vector<WX_FILENAME_SPLIT_CASE> split_cases
static

Definition at line 58 of file test_wx_filename.cpp.

Referenced by BOOST_AUTO_TEST_CASE().