mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 01:59:58 +00:00
Sensitive information masking
Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IB5IFV Signed-off-by: rentangyu <rentangyu@huawei.com>
This commit is contained in:
parent
0095d534b3
commit
c8f606c7bc
@ -634,7 +634,7 @@ static void DumpClass(TaggedObject *obj, std::ostream &os)
|
||||
DumpHClass(JSHClass::Cast(obj), os, true);
|
||||
}
|
||||
|
||||
static void DumpObject(TaggedObject *obj, std::ostream &os)
|
||||
static void DumpObject(TaggedObject *obj, std::ostream &os, bool isPrivacy)
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
auto jsHclass = obj->GetClass();
|
||||
@ -703,7 +703,7 @@ static void DumpObject(TaggedObject *obj, std::ostream &os)
|
||||
case JSType::JS_TERMINATION_ERROR:
|
||||
case JSType::JS_ARGUMENTS:
|
||||
needDumpHClass = true;
|
||||
JSObject::Cast(obj)->Dump(os);
|
||||
JSObject::Cast(obj)->Dump(os, isPrivacy);
|
||||
break;
|
||||
case JSType::JS_FUNCTION_BASE:
|
||||
needDumpHClass = true;
|
||||
@ -1306,14 +1306,14 @@ void JSTaggedValue::DumpTaggedValueType(std::ostream &os) const
|
||||
}
|
||||
}
|
||||
|
||||
void JSTaggedValue::Dump(std::ostream &os) const
|
||||
void JSTaggedValue::Dump(std::ostream &os, bool isPrivacy) const
|
||||
{
|
||||
DumpTaggedValue(os);
|
||||
os << "\n";
|
||||
|
||||
if (IsHeapObject()) {
|
||||
TaggedObject *obj = IsWeak() ? GetTaggedWeakRef() : GetTaggedObject();
|
||||
DumpObject(obj, os);
|
||||
DumpObject(obj, os, isPrivacy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1333,17 +1333,19 @@ void JSThread::DumpStack()
|
||||
handler.DumpStack(std::cout);
|
||||
}
|
||||
|
||||
void NumberDictionary::Dump(std::ostream &os) const
|
||||
void NumberDictionary::Dump(std::ostream &os, bool isPrivacy) const
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
int size = Size();
|
||||
for (int hashIndex = 0; hashIndex < size; hashIndex++) {
|
||||
JSTaggedValue key(GetKey(hashIndex));
|
||||
if (!key.IsUndefined() && !key.IsHole()) {
|
||||
JSTaggedValue val(GetValue(hashIndex));
|
||||
os << std::right << std::setw(DUMP_PROPERTY_OFFSET)
|
||||
<< static_cast<uint32_t>(JSTaggedNumber(key).GetNumber()) << ": ";
|
||||
val.DumpTaggedValue(os);
|
||||
if (!isPrivacy) {
|
||||
JSTaggedValue val(GetValue(hashIndex));
|
||||
val.DumpTaggedValue(os);
|
||||
}
|
||||
os << " ";
|
||||
DumpAttr(GetAttributes(hashIndex), false, os);
|
||||
os << "\n";
|
||||
@ -1351,18 +1353,20 @@ void NumberDictionary::Dump(std::ostream &os) const
|
||||
}
|
||||
}
|
||||
|
||||
void NameDictionary::Dump(std::ostream &os) const
|
||||
void NameDictionary::Dump(std::ostream &os, bool isPrivacy) const
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
int size = Size();
|
||||
for (int hashIndex = 0; hashIndex < size; hashIndex++) {
|
||||
JSTaggedValue key(GetKey(hashIndex));
|
||||
if (!key.IsUndefined() && !key.IsHole()) {
|
||||
JSTaggedValue val(GetValue(hashIndex));
|
||||
os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
|
||||
DumpPropertyKey(key, os);
|
||||
os << ": ";
|
||||
val.DumpTaggedValue(os);
|
||||
if (!isPrivacy) {
|
||||
JSTaggedValue val(GetValue(hashIndex));
|
||||
val.DumpTaggedValue(os);
|
||||
}
|
||||
os << " ";
|
||||
DumpAttr(GetAttributes(hashIndex), false, os);
|
||||
os << "\n";
|
||||
@ -1370,18 +1374,20 @@ void NameDictionary::Dump(std::ostream &os) const
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalDictionary::Dump(std::ostream &os) const
|
||||
void GlobalDictionary::Dump(std::ostream &os, bool isPrivacy) const
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
int size = Size();
|
||||
for (int hashIndex = 0; hashIndex < size; hashIndex++) {
|
||||
JSTaggedValue key(GetKey(hashIndex));
|
||||
if (!key.IsUndefined() && !key.IsHole()) {
|
||||
JSTaggedValue val(GetValue(hashIndex));
|
||||
os << std::right << std::setw(DUMP_PROPERTY_OFFSET);
|
||||
DumpPropertyKey(key, os);
|
||||
os << " : ";
|
||||
val.DumpTaggedValue(os);
|
||||
if (!isPrivacy) {
|
||||
JSTaggedValue val(GetValue(hashIndex));
|
||||
val.DumpTaggedValue(os);
|
||||
}
|
||||
os << " ";
|
||||
DumpAttr(GetAttributes(hashIndex), false, os);
|
||||
os << "\n";
|
||||
@ -1506,7 +1512,7 @@ void TaggedSingleList::Dump(std::ostream &os) const
|
||||
}
|
||||
}
|
||||
|
||||
void JSObject::Dump(std::ostream &os) const
|
||||
void JSObject::Dump(std::ostream &os, bool isPrivacy) const
|
||||
{
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
JSHClass *jshclass = GetJSHClass();
|
||||
@ -1529,7 +1535,7 @@ void JSObject::Dump(std::ostream &os) const
|
||||
} else {
|
||||
NumberDictionary *dict = NumberDictionary::Cast(elements);
|
||||
os << " <NumberDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
|
||||
dict->Dump(os);
|
||||
dict->Dump(os, isPrivacy);
|
||||
}
|
||||
|
||||
TaggedArray *properties = TaggedArray::Cast(GetProperties().GetTaggedObject());
|
||||
@ -1537,7 +1543,7 @@ void JSObject::Dump(std::ostream &os) const
|
||||
if (IsJSGlobalObject()) {
|
||||
GlobalDictionary *dict = GlobalDictionary::Cast(properties);
|
||||
os << " <GlobalDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
|
||||
dict->Dump(os);
|
||||
dict->Dump(os, isPrivacy);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1563,7 +1569,9 @@ void JSObject::Dump(std::ostream &os) const
|
||||
} else {
|
||||
val = properties->Get(i - static_cast<int>(jshclass->GetInlinedProperties()));
|
||||
}
|
||||
val.DumpTaggedValue(os);
|
||||
if (!isPrivacy) {
|
||||
val.DumpTaggedValue(os);
|
||||
}
|
||||
os << ") ";
|
||||
DumpAttr(attr, true, os);
|
||||
os << "\n";
|
||||
@ -1571,7 +1579,7 @@ void JSObject::Dump(std::ostream &os) const
|
||||
} else {
|
||||
NameDictionary *dict = NameDictionary::Cast(properties);
|
||||
os << " <NameDictionary[" << std::dec << dict->EntriesCount() << "]>\n";
|
||||
dict->Dump(os);
|
||||
dict->Dump(os, isPrivacy);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,12 @@ public:
|
||||
static bool inline CompKey(const std::pair<JSTaggedValue, uint32_t> &a,
|
||||
const std::pair<JSTaggedValue, uint32_t> &b);
|
||||
|
||||
DECL_DUMP()
|
||||
void Dump(std::ostream &os, bool isPrivacy = false) const DUMP_API_ATTR;
|
||||
void Dump() const DUMP_API_ATTR
|
||||
{
|
||||
Dump(std::cout);
|
||||
}
|
||||
void DumpForSnapshot(std::vector<Reference> &vec) const;
|
||||
|
||||
public:
|
||||
static constexpr int ENTRY_KEY_INDEX = 0;
|
||||
|
@ -716,7 +716,12 @@ public:
|
||||
|
||||
DECL_VISIT_OBJECT_FOR_JS_OBJECT(ECMAObject, PROPERTIES_OFFSET, SIZE)
|
||||
|
||||
DECL_DUMP()
|
||||
void Dump(std::ostream &os, bool isPrivacy = false) const DUMP_API_ATTR;
|
||||
void Dump() const DUMP_API_ATTR
|
||||
{
|
||||
Dump(std::cout);
|
||||
}
|
||||
void DumpForSnapshot(std::vector<Reference> &vec) const;
|
||||
static const CString ExtractConstructorAndRecordName(JSThread *thread, TaggedObject *obj, bool noAllocate = false,
|
||||
bool *isCallGetter = nullptr);
|
||||
|
||||
|
@ -771,7 +771,6 @@ JSTaggedValue JSTaggedValue::ToPrimitive(JSThread *thread, const JSHandle<JSTagg
|
||||
if (!valueResult.IsECMAObject()) {
|
||||
return valueResult;
|
||||
}
|
||||
DumpExceptionObject(thread, tagged);
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Cannot convert object to primitive value",
|
||||
JSTaggedValue::Exception());
|
||||
} else {
|
||||
@ -1263,6 +1262,7 @@ bool JSTaggedValue::SetPrototype(JSThread *thread, const JSHandle<JSTaggedValue>
|
||||
JSTaggedValue JSTaggedValue::GetPrototype(JSThread *thread, const JSHandle<JSTaggedValue> &obj)
|
||||
{
|
||||
if (!obj->IsECMAObject()) {
|
||||
DumpExceptionObject(thread, obj);
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Can not get Prototype on non ECMA Object", JSTaggedValue::Exception());
|
||||
}
|
||||
if (obj->IsJSProxy()) {
|
||||
@ -1807,7 +1807,7 @@ void JSTaggedValue::DumpExceptionObject(JSThread *thread, const JSHandle<JSTagge
|
||||
{
|
||||
if (thread->GetEcmaVM()->GetJSOptions().EnableExceptionBacktrace()) {
|
||||
std::ostringstream oss;
|
||||
obj->Dump(oss);
|
||||
obj->Dump(oss, true);
|
||||
std::regex reg("0x[0-9a-fA-F]+");
|
||||
std::string sensitiveStr = std::regex_replace(oss.str(), reg, "");
|
||||
LOG_ECMA(ERROR) << "DumpExceptionObject: " << sensitiveStr;
|
||||
|
@ -714,7 +714,7 @@ public:
|
||||
|
||||
void DumpTaggedValue(std::ostream &os) const DUMP_API_ATTR;
|
||||
void DumpTaggedValueType(std::ostream &os) const DUMP_API_ATTR;
|
||||
void Dump(std::ostream &os) const DUMP_API_ATTR;
|
||||
void Dump(std::ostream &os, bool isPrivacy = false) const DUMP_API_ATTR;
|
||||
void D() const DUMP_API_ATTR;
|
||||
void DumpForSnapshot(std::vector<Reference> &vec, bool isVmMode = true) const;
|
||||
static void DV(JSTaggedType val) DUMP_API_ATTR;
|
||||
|
@ -84,7 +84,12 @@ public:
|
||||
{
|
||||
return a.GetDictionaryOrder() < b.GetDictionaryOrder();
|
||||
}
|
||||
DECL_DUMP()
|
||||
void Dump(std::ostream &os, bool isPrivacy = false) const DUMP_API_ATTR;
|
||||
void Dump() const DUMP_API_ATTR
|
||||
{
|
||||
Dump(std::cout);
|
||||
}
|
||||
void DumpForSnapshot(std::vector<Reference> &vec) const;
|
||||
|
||||
static constexpr int ENTRY_KEY_INDEX = 0;
|
||||
static constexpr int ENTRY_VALUE_INDEX = 1;
|
||||
@ -139,7 +144,12 @@ public:
|
||||
ASSERT(a.IsNumber() && b.IsNumber());
|
||||
return a.GetNumber() < b.GetNumber();
|
||||
}
|
||||
DECL_DUMP()
|
||||
void Dump(std::ostream &os, bool isPrivacy = false) const DUMP_API_ATTR;
|
||||
void Dump() const DUMP_API_ATTR
|
||||
{
|
||||
Dump(std::cout);
|
||||
}
|
||||
void DumpForSnapshot(std::vector<Reference> &vec) const;
|
||||
|
||||
static constexpr int ENTRY_KEY_INDEX = 0;
|
||||
static constexpr int ENTRY_VALUE_INDEX = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user