mirror of https://github.com/ARMmbed/mbed-os.git
Cellular: clean sensitive information from trace
Information removed from the cellular subsystem trace log: * SIM pin * APN username and password Added get_debug() to ATHandler.h to get the current trace state in order to support suspend/resume of trace output.pull/9660/head
parent
f2abdcbcc6
commit
b6a0892e86
|
@ -495,7 +495,29 @@ TEST_F(TestAT_CellularContext, connect_disconnect_sync)
|
||||||
ASSERT_EQ(ctx1.disconnect(), NSAPI_ERROR_OK);
|
ASSERT_EQ(ctx1.disconnect(), NSAPI_ERROR_OK);
|
||||||
EXPECT_TRUE(ctx1.is_connected() == false);
|
EXPECT_TRUE(ctx1.is_connected() == false);
|
||||||
|
|
||||||
|
ATHandler_stub::get_debug_clear();
|
||||||
|
EXPECT_FALSE(ATHandler_stub::is_get_debug_run());
|
||||||
|
ATHandler_stub::debug_call_count_clear();
|
||||||
|
at.set_debug(true);
|
||||||
ASSERT_EQ(ctx1.connect("1234", "internet", "usern", "pwd"), NSAPI_ERROR_OK);
|
ASSERT_EQ(ctx1.connect("1234", "internet", "usern", "pwd"), NSAPI_ERROR_OK);
|
||||||
|
EXPECT_TRUE(ATHandler_stub::is_get_debug_run());
|
||||||
|
EXPECT_TRUE(ATHandler_stub::set_debug_call_count_get() == 3);
|
||||||
|
EXPECT_TRUE(at.get_debug());
|
||||||
|
EXPECT_TRUE(ctx1.is_connected() == true);
|
||||||
|
ASSERT_EQ(ctx1.disconnect(), NSAPI_ERROR_OK);
|
||||||
|
EXPECT_TRUE(ctx1.is_connected() == false);
|
||||||
|
|
||||||
|
ATHandler_stub::get_debug_clear();
|
||||||
|
EXPECT_FALSE(ATHandler_stub::is_get_debug_run());
|
||||||
|
ATHandler_stub::debug_call_count_clear();
|
||||||
|
at.set_debug(false);
|
||||||
|
ASSERT_EQ(ctx1.connect("1234", "internet", "usern", "pwd"), NSAPI_ERROR_OK);
|
||||||
|
EXPECT_TRUE(ATHandler_stub::is_get_debug_run());
|
||||||
|
EXPECT_TRUE(ATHandler_stub::set_debug_call_count_get() == 3);
|
||||||
|
EXPECT_FALSE(at.get_debug());
|
||||||
|
EXPECT_TRUE(ctx1.is_connected() == true);
|
||||||
|
ASSERT_EQ(ctx1.disconnect(), NSAPI_ERROR_OK);
|
||||||
|
EXPECT_TRUE(ctx1.is_connected() == false);
|
||||||
|
|
||||||
// More connect test after we are re-writted getting of PDP context...
|
// More connect test after we are re-writted getting of PDP context...
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,6 +315,35 @@ TEST_F(TestAT_CellularDevice, test_AT_CellularDevice_create_delete_context)
|
||||||
delete dev;
|
delete dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAT_CellularDevice, TestAT_CellularDevice_set_pin_verify_debug)
|
||||||
|
{
|
||||||
|
EventQueue que;
|
||||||
|
FileHandle_stub fh1;
|
||||||
|
ATHandler at(&fh1, que, 0, ",");
|
||||||
|
AT_CellularDevice *dev = new AT_CellularDevice(&fh1);
|
||||||
|
|
||||||
|
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||||
|
ATHandler_stub::get_debug_clear();
|
||||||
|
EXPECT_FALSE(ATHandler_stub::is_get_debug_run());
|
||||||
|
ATHandler_stub::debug_call_count_clear();
|
||||||
|
at.set_debug(true);
|
||||||
|
EXPECT_TRUE(NSAPI_ERROR_OK == dev->set_pin("12"));
|
||||||
|
EXPECT_TRUE(ATHandler_stub::is_get_debug_run());
|
||||||
|
EXPECT_TRUE(ATHandler_stub::set_debug_call_count_get() == 3);
|
||||||
|
EXPECT_TRUE(at.get_debug());
|
||||||
|
|
||||||
|
ATHandler_stub::get_debug_clear();
|
||||||
|
EXPECT_FALSE(ATHandler_stub::is_get_debug_run());
|
||||||
|
ATHandler_stub::debug_call_count_clear();
|
||||||
|
at.set_debug(false);
|
||||||
|
EXPECT_TRUE(NSAPI_ERROR_OK == dev->set_pin("11"));
|
||||||
|
EXPECT_TRUE(ATHandler_stub::is_get_debug_run());
|
||||||
|
EXPECT_TRUE(ATHandler_stub::set_debug_call_count_get() == 3);
|
||||||
|
EXPECT_FALSE(at.get_debug());
|
||||||
|
|
||||||
|
delete dev;
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(TestAT_CellularDevice, TestAT_CellularDevice_set_pin)
|
TEST_F(TestAT_CellularDevice, TestAT_CellularDevice_set_pin)
|
||||||
{
|
{
|
||||||
FileHandle_stub fh1;
|
FileHandle_stub fh1;
|
||||||
|
|
|
@ -57,6 +57,29 @@ int ATHandler_stub::urc_amount = 0;
|
||||||
mbed::Callback<void()> ATHandler_stub::callback[kATHandler_urc_table_max_size];
|
mbed::Callback<void()> ATHandler_stub::callback[kATHandler_urc_table_max_size];
|
||||||
char *ATHandler_stub::urc_string_table[kATHandler_urc_table_max_size] = {'\0'};
|
char *ATHandler_stub::urc_string_table[kATHandler_urc_table_max_size] = {'\0'};
|
||||||
|
|
||||||
|
bool ATHandler_stub::get_debug_flag = false;
|
||||||
|
uint8_t ATHandler_stub::set_debug_call_count = 0;
|
||||||
|
|
||||||
|
bool ATHandler_stub::is_get_debug_run()
|
||||||
|
{
|
||||||
|
return ATHandler_stub::get_debug_flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ATHandler_stub::get_debug_clear()
|
||||||
|
{
|
||||||
|
ATHandler_stub::get_debug_flag = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ATHandler_stub::set_debug_call_count_get()
|
||||||
|
{
|
||||||
|
return ATHandler_stub::set_debug_call_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ATHandler_stub::debug_call_count_clear()
|
||||||
|
{
|
||||||
|
ATHandler_stub::set_debug_call_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, uint32_t timeout, const char *output_delimiter, uint16_t send_delay) :
|
ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, uint32_t timeout, const char *output_delimiter, uint16_t send_delay) :
|
||||||
_nextATHandler(0),
|
_nextATHandler(0),
|
||||||
_fileHandle(fh),
|
_fileHandle(fh),
|
||||||
|
@ -76,9 +99,17 @@ ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, uint32_t timeout, const
|
||||||
|
|
||||||
void ATHandler::set_debug(bool debug_on)
|
void ATHandler::set_debug(bool debug_on)
|
||||||
{
|
{
|
||||||
|
++ATHandler_stub::set_debug_call_count;
|
||||||
ATHandler_stub::debug_on = debug_on;
|
ATHandler_stub::debug_on = debug_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ATHandler::get_debug() const
|
||||||
|
{
|
||||||
|
ATHandler_stub::get_debug_flag = true;
|
||||||
|
|
||||||
|
return ATHandler_stub::debug_on;
|
||||||
|
}
|
||||||
|
|
||||||
ATHandler::~ATHandler()
|
ATHandler::~ATHandler()
|
||||||
{
|
{
|
||||||
ATHandler_stub::ref_count = kATHandler_destructor_ref_ount;
|
ATHandler_stub::ref_count = kATHandler_destructor_ref_ount;
|
||||||
|
|
|
@ -64,6 +64,13 @@ extern int resp_stop_success_count;
|
||||||
extern bool process_oob_urc;
|
extern bool process_oob_urc;
|
||||||
extern int urc_amount;
|
extern int urc_amount;
|
||||||
extern char *urc_string_table[kATHandler_urc_table_max_size];
|
extern char *urc_string_table[kATHandler_urc_table_max_size];
|
||||||
|
|
||||||
|
extern bool get_debug_flag;
|
||||||
|
bool is_get_debug_run();
|
||||||
|
void get_debug_clear();
|
||||||
|
extern uint8_t set_debug_call_count;
|
||||||
|
uint8_t set_debug_call_count_get();
|
||||||
|
void debug_call_count_clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -112,6 +112,11 @@ void ATHandler::set_debug(bool debug_on)
|
||||||
_debug_on = debug_on;
|
_debug_on = debug_on;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ATHandler::get_debug() const
|
||||||
|
{
|
||||||
|
return _debug_on;
|
||||||
|
}
|
||||||
|
|
||||||
ATHandler::~ATHandler()
|
ATHandler::~ATHandler()
|
||||||
{
|
{
|
||||||
while (_oobs) {
|
while (_oobs) {
|
||||||
|
|
|
@ -431,6 +431,13 @@ public: // just for debugging
|
||||||
*/
|
*/
|
||||||
void set_debug(bool debug_on);
|
void set_debug(bool debug_on);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get degug state set by @ref set_debug
|
||||||
|
*
|
||||||
|
* @return current state of debug
|
||||||
|
*/
|
||||||
|
bool get_debug() const;
|
||||||
|
|
||||||
/** Set debug_on for all ATHandlers in the _atHandlers list
|
/** Set debug_on for all ATHandlers in the _atHandlers list
|
||||||
*
|
*
|
||||||
* @param debug_on Set true to enable debug traces
|
* @param debug_on Set true to enable debug traces
|
||||||
|
|
|
@ -315,8 +315,15 @@ nsapi_error_t AT_CellularContext::do_user_authentication()
|
||||||
_at.cmd_start("AT+CGAUTH=");
|
_at.cmd_start("AT+CGAUTH=");
|
||||||
_at.write_int(_cid);
|
_at.write_int(_cid);
|
||||||
_at.write_int(_authentication_type);
|
_at.write_int(_authentication_type);
|
||||||
|
|
||||||
|
const bool stored_debug_state = _at.get_debug();
|
||||||
|
_at.set_debug(false);
|
||||||
|
|
||||||
_at.write_string(_uname);
|
_at.write_string(_uname);
|
||||||
_at.write_string(_pwd);
|
_at.write_string(_pwd);
|
||||||
|
|
||||||
|
_at.set_debug(stored_debug_state);
|
||||||
|
|
||||||
_at.cmd_stop_read_resp();
|
_at.cmd_stop_read_resp();
|
||||||
if (_at.get_last_error() != NSAPI_ERROR_OK) {
|
if (_at.get_last_error() != NSAPI_ERROR_OK) {
|
||||||
return NSAPI_ERROR_AUTH_FAILURE;
|
return NSAPI_ERROR_AUTH_FAILURE;
|
||||||
|
|
|
@ -176,7 +176,14 @@ nsapi_error_t AT_CellularDevice::set_pin(const char *sim_pin)
|
||||||
|
|
||||||
_at->lock();
|
_at->lock();
|
||||||
_at->cmd_start("AT+CPIN=");
|
_at->cmd_start("AT+CPIN=");
|
||||||
|
|
||||||
|
const bool stored_debug_state = _at->get_debug();
|
||||||
|
_at->set_debug(false);
|
||||||
|
|
||||||
_at->write_string(sim_pin);
|
_at->write_string(sim_pin);
|
||||||
|
|
||||||
|
_at->set_debug(stored_debug_state);
|
||||||
|
|
||||||
_at->cmd_stop_read_resp();
|
_at->cmd_stop_read_resp();
|
||||||
return _at->unlock_return_error();
|
return _at->unlock_return_error();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue