本文說明參考架構,說明如何搭配使用 Cloud Data Loss Prevention (DLP) API 和 Google Cloud 適用的 ABAP SDK 的 SAP BTP 版本,保護 SAP 中的機密企業資料。
保護企業機密資料 (例如儲存在 SAP 中的個人識別資訊 (PII)) 至關重要。將 SAP 中的敏感企業資料分享給錯誤的使用者或系統,可能會損害貴公司的聲譽,並導致財務損失。DLP API 提供功能強大且彈性的機制,可為機密資料增添一層保護機制。這個 API 可在機密資訊儲存至 SAP 或從 SAP 傳輸前,進行探索、分類及去識別化。這項功能可協助您主動識別及保護機密資訊,降低資料外洩風險,並確保遵循隱私權法規。
本文件的目標讀者包括 ABAP 開發人員、SAP 解決方案架構師和雲端架構師,他們負責資料安全性、資料處理或資料分析。本文件假設您熟悉資料處理和資料隱私、機密資料保護和相關概念,例如 InfoType 和 infoType 偵測器。
架構
下圖顯示 DLP 解決方案的參考架構,包含 SAP BTP ABAP 環境和 Google Cloud的元件。
這個 DLP 解決方案架構包含下列元件:
元件 | 子系統 | 詳細資料 |
---|---|---|
1 | 輸入來源 | 做為資料的進入點。 |
2 | 客戶服務 | 與所有其他元件互動的 ABAP 類別。它會接收來源資料,透過 ABAP SDK for Google Cloud 將資料傳送至 DLP API 進行處理,並將經過處理的資料儲存在 SAP Datastore 中。 |
3 | ABAP SDK for Google Cloud | 用於存取 DLP API 的 Google Cloud 適用 SAP BTP 版 ABAP SDK。 |
4 | DLP API | DLP API 提供各種轉換方法,可用於去識別化 PII。 |
5 | 目標資料儲存庫 | 在雲端或內部部署環境中執行的 SAP ERP 系統,在處理及去識別化 PII 後,系統會將資料儲存在該系統中。 |
使用的產品
此參考架構使用以下 Google Cloud 產品:
用途
本節提供範例,說明您可以使用 DLP API 保護 SAP 中的機密企業資料。
遵循資料隱私權法規
機構通常需要去識別機密資料。許多政府政策 (例如 GDPR 和 DPDP) 規定在特定情況下不得儲存 PII。
費用
如要預估 DLP API 使用的 Google Cloud 資源費用,請參閱 Google Cloud Pricing Calculator 中預先計算的預估值。
設計替代方案
雖然本文件著重於 ABAP SDK for Google Cloud 的 SAP BTP 版本,但您也可以使用 ABAP SDK for Google Cloud 的內部或任何雲端版本,取得類似的結果。在這種設定中,您可以在內部部署的 SAP 系統中儲存經過處理且去識別化的個人資訊 (PII)。
部署作業
本節說明如何部署解決方案,在 SAP 系統中建立商業夥伴 (人員) 時保護機密資料。這項解決方案可根據貴機構設定的規則,遮蓋、去識別或匿名化資料。
事前準備
在根據這個參考架構導入解決方案之前,請確認您已完成下列先決條件:
您擁有 Google Cloud 帳戶和專案。
專案已啟用計費功能。如要瞭解如何確認專案已啟用計費功能,請參閱「驗證專案的帳單狀態」。
已設定驗證方法,以便存取 Google Cloud API。如要瞭解如何設定驗證機制,請參閱「為 Google Cloud 適用的 ABAP SDK 的 SAP BTP 版本設定驗證機制」。
Google Cloud 專案已啟用 DLP API。
實作用於去識別化個人識別資訊的用戶端服務
資料來源的輸入內容會在您在 SAP BTP ABAP 環境中實作的用戶端服務中處理。這個用戶端服務可包含下列子元件:
- 規則設定:儲存需要套用於不同類型 PII 相關欄位的業務規則。
- DLP Proxy 模組:透過 SAP BTP 版的 ABAP SDK for Google Cloud 呼叫 DLP API。
規則設定
在 SAP BTP ABAP 環境中,您可以建立設定表,以維護需要針對不同類型的 PII 相關欄位套用的轉換規則。在實際工作環境中,您可以使用 SAP Fiori 等工具維護這個表格中的資料。
您可以實作下列規則範例:
- 任何含有電子郵件地址的欄位都必須替換為虛擬值。
- 任何含有電話號碼的欄位都必須遮蓋。
- 任何含有註解、附註或備註的欄位,不得包含任何與電子郵件地址相關的資訊。
- 任何含有銀行帳戶詳細資料的欄位,都必須使用加密技術的去識別方法進行權杖化。
以下是設定範例表格的定義:
define table zgoog_dlp_config {
key client : abap.clnt not null;
key keyword : abap.char(60) not null;
key infotype : abap.char(60) not null;
surrogate_infotype : abap.char(60);
common_alphabhet : abap.char(20);
masking_char : abap.char(1);
number_to_mask : int4;
}
以下範例顯示轉換規則範例:
lt_dlp_config = VALUE #(
( client = sy-mandt keyword = 'EMAIL' infotype = 'EMAIL_ADDRESS' )
( client = sy-mandt keyword = 'PHONE NUMBER' infotype = 'PHONE_NUMBER' number_to_mask = 5 masking_char = '*' )
( client = sy-mandt keyword = 'REMARKS' infotype = 'EMAIL_ADDRESS' )
( client = sy-mandt keyword = 'REMARKS' infotype = 'PHONE_NUMBER' )
( client = sy-mandt keyword = 'BANK ACCOUNT' infotype = 'FINANCIAL_ACCOUNT_NUMBER' surrogate_infotype = 'ACCOUNT' common_alphabhet = 'ALPHA_NUMERIC' )
).
資料遺失防護 Proxy 模組
您可以建立名為「資料遺失防護 Proxy 模組」的專屬子元件。這個模組可以是 ABAP 類別或 REST 服務。其主要功能是使用您先前定義的轉換規則,將 PII 去識別化。
DLP 代理程式模組會使用 Google Cloud ABAP SDK 的 SAP BTP 版本中 /GOOG/CL_DLP_V2
類別的 DEIDENTIFY_CONTENT
方法。
以下各節將說明如何在各種情境下,使用 DLP 代理程式模組去識別個人識別資訊的實作範例。
替換:將偵測到的機密值替換為指定代理值
如要將偵測到的電子郵件 ID 替換為通用值,請執行下列步驟:
為
/GOOG/CL_DLP_V2
類別建立用戶端物件。請參閱設定表,決定要套用的轉換類型。
如要遮蔽電子郵件 ID,請將其替換為
EMAIL_ID@EXAMPLE.COM
等替換值。呼叫 DLP API。
使用
DEIDENTIFY_CONTENT
方法搭配所有相關參數 (包括替換值),並將輸出內容傳回至用戶端服務。
以下程式碼範例說明上述步驟:
DATA: ls_input TYPE /goog/cl_dlp_v2=>ty_055,
ls_transformations TYPE /goog/cl_dlp_v2=>ty_100.
TRY.
DATA(lo_client) = NEW /goog/cl_dlp_v2( iv_key_name = 'CLIENT_KEY' ).
DATA(lv_p_projects_id) = CONV string( lo_client->gv_project_id ).
"As a developer, you need to read the configuration into mt_dlp_config
TRY.
"As a developer, you need to read the configuration
DATA(ls_dlp_config) = mt_dlp_config[ keyword = iv_input_type ].
"Populate the input parameters to DLP API for replacement
INSERT VALUE #( name = ls_dlp_config-infotype ) INTO TABLE ls_input-inspect_config-info_types.ls_transformations-primitive_transformation-replace_config-new_value-string_value = 'REPLACEMENT_VALUE'.
INSERT ls_transformations INTO TABLE ls_input-deidentify_config-info_type_transformations-transformations.
ls_input-item-value = iv_input_value.
"Call DLP API client stub
TRY.
lo_client->deidentify_content(
EXPORTING
iv_p_projects_id = lv_p_projects_id
is_input = ls_input
IMPORTING
es_output = DATA(ls_output)
ev_ret_code = DATA(lv_ret_code)
ev_err_text = DATA(lv_err_text)
).
CATCH /goog/cx_sdk INTO DATA(lx_sdk_exception).
ev_message = lx_sdk_exception->get_text( ).
ENDTRY.
IF lo_client->is_success( lv_ret_code ).
ev_message = lv_err_text.
ELSE.
ev_output_value = ls_output-item-value.
ENDIF.
CATCH cx_sy_itab_line_not_found INTO DATA(lx_not_found).
ev_output_value = iv_input_value.
ENDTRY.
"Close the http client
lo_client->close_http_client( ).
CATCH /goog/cx_sdk INTO DATA(lx_sdk).
ev_message = lx_sdk->get_text( ).
ENDTRY.
更改下列內容:
CLIENT_KEY
:用於驗證的用戶端金鑰。REPLACEMENT_VALUE
:替換值,例如EMAIL_ID@EXAMPLE.COM
。
刪減:刪除所有或部分偵測到的機密值
如要刪除所有或部分偵測到的機密值,請執行下列步驟:
為
/GOOG/CL_DLP_V2
類別建立用戶端物件。請參閱設定表,決定要套用的轉換類型。
指定刪除所有或部分偵測到的機密值。
呼叫 DLP API。
使用
DEIDENTIFY_CONTENT
方法搭配所有相關參數,並將輸出內容傳回至用戶端服務。
DATA: ls_input TYPE /goog/cl_dlp_v2=>ty_055,
ls_transformations TYPE /goog/cl_dlp_v2=>ty_100,
lo_redact TYPE REF TO data.
DATA(lo_client) = NEW /goog/cl_dlp_v2( iv_key_name = 'CLIENT_KEY' ).
DATA(lv_p_projects_id) = CONV string( lo_client->gv_project_id ).
"As a developer, you need to read the configuration into mt_dlp_config
TRY.
"Read the configuration
DATA(ls_dlp_config) = mt_dlp_config[ keyword = iv_input_type ].
"Populate the input parameters to DLP API for redaction
CREATE DATA lo_redact TYPE REF TO string.
INSERT VALUE #( name = ls_dlp_config-infotype ) INTO TABLE ls_input-inspect_config-info_types.
INSERT VALUE #( name = ls_dlp_config-infotype ) INTO TABLE ls_transformations-info_types.
ls_transformations-primitive_transformation-redact_config = lo_redact.
INSERT ls_transformations INTO TABLE ls_input-deidentify_config-info_type_transformations-transformations.
ls_input-item-value = iv_input_value.
"Call DLP API client stub
TRY.
lo_client->deidentify_content(
EXPORTING
iv_p_projects_id = lv_p_projects_id
is_input = ls_input
IMPORTING
es_output = DATA(ls_output)
ev_ret_code = DATA(lv_ret_code)
ev_err_text = DATA(lv_err_text)
).
CATCH /goog/cx_sdk INTO lx_sdk_exception.
ev_message = lx_sdk_exception->get_text( ).
ENDTRY.
IF lo_client->is_success( lv_ret_code ).
ev_message = lv_err_text.
ELSE.
ev_output_value = ls_output-item-value.
ENDIF.
CATCH cx_sy_itab_line_not_found INTO lx_not_found.
ev_output_value = iv_input_value.
ENDTRY.
"Close the http client
lo_client->close_http_client( ).
CATCH /goog/cx_sdk INTO DATA(lx_sdk).
ev_message = lx_sdk->get_text( ).
ENDTRY.
將 CLIENT_KEY
替換為用於驗證的用戶端金鑰。
遮蔽:將機密值的多個字元替換為指定字元,例如井字號 (#) 或星號 (*)
如要將值替換為指定的字元,請執行下列步驟:
為
/GOOG/CL_DLP_V2
類別建立用戶端物件。請參閱設定表,決定要套用的轉換類型。
根據設定表設定遮蔽字元和要遮蔽的字元數量。
呼叫 DLP API。
使用
DEIDENTIFY_CONTENT
方法搭配所有相關參數 (包括替換值),並將輸出內容傳回至用戶端服務。
DATA: ls_input TYPE /goog/cl_dlp_v2=>ty_055,
ls_transformations TYPE /goog/cl_dlp_v2=>ty_100.
TRY.
DATA(lo_client) = NEW /goog/cl_dlp_v2( iv_key_name = 'CLIENT_KEY' ).
DATA(lv_p_projects_id) = CONV string( lo_client->gv_project_id ).
"As a developer, you need to read the configuration into mt_dlp_config
TRY.
"Read the configuration
DATA(ls_dlp_config) = mt_dlp_config[ keyword = iv_input_type ].
"Populate the input parameters to DLP API for masking
INSERT VALUE #( name = ls_dlp_config-infotype ) INTO TABLE ls_input-inspect_config-info_types.
ls_transformations-primitive_transformation-character_mask_config-number_to_mask = ls_dlp_config-number_to_mask.
ls_transformations-primitive_transformation-character_mask_config-masking_character = ls_dlp_config-masking_char.
INSERT ls_transformations INTO TABLE ls_input-deidentify_config-info_type_transformations-transformations.
ls_input-item-value = iv_input_value.
"Call DLP API client stub
TRY.
lo_client->deidentify_content(
EXPORTING
iv_p_projects_id = lv_p_projects_id
is_input = ls_input
IMPORTING
es_output = DATA(ls_output)
ev_ret_code = DATA(lv_ret_code)
ev_err_text = DATA(lv_err_text)
).
CATCH /goog/cx_sdk INTO lx_sdk_exception.
ev_message = lx_sdk_exception->get_text( ).
ENDTRY.
IF lo_client->is_success( lv_ret_code ).
ev_message = lv_err_text.
ELSE.
ev_output_value = ls_output-item-value.
ENDIF.
CATCH cx_sy_itab_line_not_found INTO lx_not_found.
ev_output_value = iv_input_value.
ENDTRY.
"Close the http client
lo_client->close_http_client( ).
CATCH /goog/cx_sdk INTO DATA(lx_sdk).
ev_message = lx_sdk->get_text( ).
ENDTRY.
將 CLIENT_KEY
替換為用於驗證的用戶端金鑰。
加密式代碼化:使用加密編譯金鑰加密原始機密資料值
如要使用加密式代碼化,您必須建立加密金鑰和包裝金鑰。本指南使用格式保留加密。這個方法會建立與原始輸入值長度和字元相同的符記。
如要使用加密雜湊對應功能去識別機密資料值,請執行下列步驟:
為
/GOOG/CL_DLP_V2
類別建立用戶端物件。請參閱設定表,決定要套用的轉換類型。
設定先前建立的加密金鑰和已包裝金鑰。
呼叫 DLP API。
使用
DEIDENTIFY_CONTENT
方法搭配所有相關參數進行加密編譯,並將輸出內容傳回至用戶端服務。
DATA: ls_input TYPE /goog/cl_dlp_v2=>ty_055,
ls_transformations TYPE /goog/cl_dlp_v2=>ty_100,
ls_kms_wrapped_key TYPE /goog/cl_dlp_v2=>ty_123,
ls_crypto_key TYPE /goog/cl_dlp_v2=>ty_040,
ls_crypto_hash_config TYPE /goog/cl_dlp_v2=>ty_039.
TRY.
DATA(lo_client) = NEW /goog/cl_dlp_v2( iv_key_name = 'CLIENT_KEY' ).
DATA(lv_p_projects_id) = CONV string( lo_client->gv_project_id ).
"As a developer, you need to read the configuration into lt_dlp_config
"As a developer, you need to populate the crypto key name and wrapped key
ls_kms_wrapped_key-crypto_key_name = 'CRYPTO_KEY_NAME'. "Crypto_key_name.
ls_kms_wrapped_key-wrapped_key = 'WRAPPED_KEY_NAME'. "Wrapped_key.
ls_crypto_key-kms_wrapped = ls_kms_wrapped_key.
ls_crypto_hash_config-crypto_key = ls_crypto_key.
TRY.
"Read the configuration
DATA(ls_dlp_config) = mt_dlp_config[ keyword = iv_input_type ].
"Populate the input parameters to DLP API for cryptographic encryption
INSERT VALUE #( name = ls_dlp_config-infotype ) INTO TABLE ls_input-inspect_config-info_types.
INSERT VALUE #( name = ls_dlp_config-infotype ) INTO TABLE ls_transformations-info_types. ls_transformations-primitive_transformation-crypto_replace_ffx_fpe_config-crypto_key-kms_wrapped = ls_kms_wrapped_key. ls_transformations-primitive_transformation-crypto_replace_ffx_fpe_config-surrogate_info_type-name = ls_dlp_config-surrogate_infotype. ls_transformations-primitive_transformation-crypto_replace_ffx_fpe_config-common_alphabet = ls_dlp_config-common_alphabhet.
INSERT ls_transformations INTO TABLE ls_input-deidentify_config-info_type_transformations-transformations.
ls_input-item-value = iv_input_value.
"Add the info type identification string to map the subsequent value to relevant infotype
CONCATENATE 'Bank Account' ls_input-item-value INTO ls_input-item-value SEPARATED BY space.
"Call DLP API client stub
TRY.
lo_client->deidentify_content(
EXPORTING
iv_p_projects_id = lv_p_projects_id
is_input = ls_input
IMPORTING
es_output = DATA(ls_output)
ev_ret_code = DATA(lv_ret_code)
ev_err_text = DATA(lv_err_text)
).
CATCH /goog/cx_sdk INTO DATA(lx_sdk_exception).
ev_message = lx_sdk_exception->get_text( ).
ENDTRY.
IF lo_client->is_success( lv_ret_code ).
ev_message = lv_err_text.
ELSE.
"Removing the info type identification string added earlier and keeping only the encrypted value
REPLACE ALL OCCURRENCES OF SUBSTRING 'Bank Account' IN ls_output-item-value WITH ''.
REPLACE ALL OCCURRENCES OF SUBSTRING 'ACCOUNT(10):' IN ls_output-item-value WITH ''.
ev_output_value = ls_output-item-value.
ENDIF.
CATCH cx_sy_itab_line_not_found INTO lx_not_found.
ev_output_value = iv_input_value.
ENDTRY.
"Close the http client
lo_client->close_http_client( ).
CATCH /goog/cx_sdk INTO DATA(lx_sdk).
ev_message = lx_sdk->get_text( ).
ENDTRY.
更改下列內容:
CLIENT_KEY
:用於驗證的用戶端金鑰。CRYPTO_KEY_NAME
:加密編譯金鑰名稱。WRAPPED_KEY_NAME
:已包裝的鍵名稱。
將輸入資料傳送至用戶端服務
將資料從輸入來源系統傳送至用戶端服務。您可以使用 API 呼叫、前端 UI 應用程式、本機檔案、第三方應用程式或任何其他來源來傳輸資料。
如要瞭解如何建構 SAP Fiori 應用程式,請參閱「使用 ABAP RESTful 應用程式程式設計模式建構 SAP Fiori 應用程式」。
呼叫 DLP 代理程式模組
從接收來源輸入的用戶端服務呼叫 DLP 代理程式模組。
以下程式碼範例說明如何從用戶端服務呼叫 DLP 代理程式模組:
DATA : lv_input TYPE string,
lv_output TYPE String.
"As a developer, you need to populate input data into relevant fields
"Redaction: Deletes all or part of a detected sensitive value
" - Remarks
lv_input = lv_email_address.
zgoog_cl_dlp_proxy=>call_dlp( EXPORTING iv_input_value = lv_input iv_input_type = 'EMAIL'
IMPORTING ev_output_value = lv_output ev_message = ev_message ).
ls_bupa_email_address-email_address = lv_output.
"Masking: Replaces a number of characters of a sensitive value with a specified surrogate character, such as a hash (#) or asterisk (*).
" - Phone Number
lv_input = lv_phone_number.
zgoog_cl_dlp_proxy=>call_dlp( EXPORTING iv_input_value = lv_input iv_input_type = 'PHONE NUMBER'
IMPORTING ev_output_value = lv_output ev_message = ev_message ).
ls_bupa_phone_number-phone_number = lv_output.
"Replacement: Replaces a detected sensitive value with a specified surrogate value.
" - Email ID
lv_input = lv_address_comm_remarks.
zgoog_cl_dlp_proxy=>call_dlp( EXPORTING iv_input_value = lv_input iv_input_type = 'REMARKS'
IMPORTING ev_output_value = lv_output ev_message = ev_message ).
ls_bupa_email_address-address_comm_remarks = lv_output.
"Crypto-based tokenization: Encrypts the original sensitive data value by using a cryptographic key. Sensitive Data Protection supports several types of tokenization,
"including transformations that can be reversed, or "re-identified."
" - Bank account number
lv_input = lv_bank_account.
zgoog_cl_dlp_proxy=>call_dlp( EXPORTING iv_input_value = lv_input iv_input_type = 'BANK ACCOUNT'
IMPORTING ev_output_value = lv_output ev_message = ev_message ).
ls_bupa_bank_details-bank_account = lv_output.
將資料儲存在 SAP ERP 系統中
相關欄位已去識別化後,請在用戶端服務中實作邏輯,將資料儲存至目標儲存空間。這可以是 Cloud Storage 服務或內部部署的 SAP 系統。
後續步驟
如要以最少的力氣部署本指南中說明的範例解決方案,請使用 GitHub 提供的程式碼範例。
探索 DLP API 提供的各種轉換方法,找出最符合您特定業務需求的做法。
如要瞭解 ABAP SDK for Google Cloud,請參閱「ABAP SDK for Google Cloud 簡介」。
如需協助解決 ABAP SDK for Google Cloud 的問題,請按照下列步驟操作:
- 請參閱 ABAP SDK for Google Cloud 疑難排解指南。
- 在 Cloud 論壇上向社群提問,並討論 ABAP 適用的 Google Cloud SDK。
- 收集所有可用的診斷資訊,然後聯絡 Cloud 客戶服務團隊。如要瞭解如何與 Customer Care 聯絡,請參閱「取得 SAP 支援 Google Cloud」一文。
貢獻者
作者:Sanchita Mohta | SAP 應用程式工程師
其他協作者: Vikash Kumar | 技術撰稿人