From: sangsoo lee Date: Fri, 19 Apr 2013 08:20:53 +0000 (+0900) Subject: add untrusted source check and invalid package check X-Git-Tag: accepted/tizen_2.1/20130425.023719~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dbcec79526011ad4477794c76b1ec05426f2d646;p=apps%2Fosp%2FInstaller.git add untrusted source check and invalid package check Change-Id: If75c8e5650a07860e775fab8efbcd1e5444a103f --- diff --git a/inc/IstDetailForm.h b/inc/IstDetailForm.h index 93cd392..01e9a28 100644 --- a/inc/IstDetailForm.h +++ b/inc/IstDetailForm.h @@ -93,6 +93,8 @@ private: int __itemCount; bool __isInstalled; + bool __isValidPackage; + bool __isUntrustedSource; bool __isUpdatable; }; diff --git a/src/IstDetailForm.cpp b/src/IstDetailForm.cpp index 2f7476e..7af3f74 100644 --- a/src/IstDetailForm.cpp +++ b/src/IstDetailForm.cpp @@ -135,13 +135,19 @@ DetailForm::GetDescriptionInfo(int groupIndex, int itemIndex, String& name, Stri PrivilegeInfo* pPrivilege = null; TryReturn(groupIndex == 0, E_FAILURE, "Group Index Error"); + if (__pPrivilegeList != null){ pPrivilege = dynamic_cast (__pPrivilegeList->GetAt(itemIndex)); } + else{ + AppLogException("__pPrivilegeList is empty"); + } if (pPrivilege != null){ pPrivilege->GetDisplayName().IsEmpty() == false ? name = pPrivilege->GetDisplayName() : name = ""; pPrivilege->GetDescription().IsEmpty() == false ? description = pPrivilege->GetDescription() : description = ""; + AppLog("name : %ls", name.GetPointer()); + AppLog("description : %ls", description.GetPointer()); } return E_SUCCESS; @@ -161,6 +167,16 @@ DetailForm::ParsingTPK() __pTargetPackageInfo = pMgr->GetPackageInfoFromFileN(filePath); TryReturn(__pTargetPackageInfo != null, GetLastResult(), "[%s] Package Path is not delivered", GetErrorMessage(GetLastResult())) + String UNTRUSTED_SOURCE = L"UnknownSrc"; + if (__pTargetPackageInfo->GetStoreClientId().IsEmpty()){ + AppLogException("Store Client id is Empty"); + } + else if (__pTargetPackageInfo->GetStoreClientId().CompareTo(UNTRUSTED_SOURCE) == 0){ + __isUntrustedSource = true; + } + __isUntrustedSource = true; + AppLog("Store resource id : %ls", __pTargetPackageInfo->GetStoreClientId().GetPointer()); + __pHeader->SetTitleText(__pTargetPackageInfo->GetDisplayName()); packageId = __pTargetPackageInfo->GetId().GetPointer(); TryReturn(packageId.IsEmpty() == false, E_FAILURE, "pakcageId is Empty!!!"); @@ -208,8 +224,13 @@ DetailForm::ParsingTPK() } __pPrivilegeList = __pTargetPackageInfo->GetPrivilegeListN(); - if (__pPrivilegeList) { + result res = GetLastResult(); + TryReturn(res == E_SUCCESS, res, "[%s] GetPrivilegeListN() error occurred", GetErrorMessage(res)); + + if (__pPrivilegeList) + { __itemCount = __pPrivilegeList->GetCount(); + AppLog("item count : %d ", __itemCount); } else{ AppLog("No Privilege List"); @@ -235,8 +256,8 @@ void DetailForm::SetInfoTextBox() { String installMsg = L"Do you want to install this application?\n\nAllow this application to:"; - if (__isInstalled){ - installMsg.Append(L"\n\n(application will be updated)"); + if (__isUntrustedSource){ + installMsg.Append(L"\n\n(Unknown sources)"); } __pTextBox = static_cast(GetControl(L"IDC_INFO_TEXTBOX")); __pTextBox->SetText(installMsg); @@ -290,9 +311,14 @@ DetailForm::SetPopupControl() InstallerApp* pUiApp = static_cast(UiApp::GetInstance()); String packagePath = pUiApp->GetPackagePath(); - if (packagePath.IsEmpty() || pUiApp->IsValidAccess() == false) + if (packagePath.IsEmpty() || pUiApp->IsValidAccess() == false || !__isValidPackage) { - pTextBox->SetText(L"Wrong Execution."); + if (!__isValidPackage){ + pTextBox->SetText(L"Invalid Package."); + } + else{ + pTextBox->SetText(L"Wrong Execution."); + } __pPopup->AddControl(pTextBox); pButtonClose->SetPosition(X_CANCEL_BTN_ALONE, pButtonClose->GetY()); __pPopup->AddControl(pButtonClose); @@ -353,8 +379,13 @@ DetailForm::OnInitializing(void) __itemCount = 0; __isUpdatable = false; __isInstalled = false; + __isValidPackage = true; // parsing tpk package info then get and set item count - ParsingTPK(); + r = ParsingTPK(); + if (r != E_SUCCESS) + { + __isValidPackage = false; + } // Install Confirmation Popup SetPopupControl();