- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试让用于 Python 的 Google Cloud Platform 数据丢失防护 (DLP) 客户端库在 SSL 代理后面工作: https://cloud.google.com/dlp/docs/libraries#client-libraries-usage-python
我正在使用文档中的代码片段:
# Import the client library
import google.cloud.dlp
import os
import subprocess
import json
import requests
import getpass
import urllib.parse
import logging
logging.basicConfig(level=logging.DEBUG)
# Instantiate a client.
dlp_client = google.cloud.dlp.DlpServiceClient()
# The string to inspect
content = 'Robert Frost'
# Construct the item to inspect.
item = {'value': content}
# The info types to search for in the content. Required.
info_types = [{'name': 'FIRST_NAME'}, {'name': 'LAST_NAME'}]
# The minimum likelihood to constitute a match. Optional.
min_likelihood = 'LIKELIHOOD_UNSPECIFIED'
# The maximum number of findings to report (0 = server maximum). Optional.
max_findings = 0
# Whether to include the matching string in the results. Optional.
include_quote = True
# Construct the configuration dictionary. Keys which are None may
# optionally be omitted entirely.
inspect_config = {
'info_types': info_types,
'min_likelihood': min_likelihood,
'include_quote': include_quote,
'limits': {'max_findings_per_request': max_findings},
}
# Convert the project id into a full resource id.
parent = dlp_client.project_path('my-project-id')
# Call the API.
response = dlp_client.inspect_content(parent, inspect_config, item)
# Print out the results.
if response.result.findings:
for finding in response.result.findings:
try:
print('Quote: {}'.format(finding.quote))
except AttributeError:
pass
print('Info type: {}'.format(finding.info_type.name))
# Convert likelihood value to string respresentation.
likelihood = (google.cloud.dlp.types.Finding.DESCRIPTOR
.fields_by_name['likelihood']
.enum_type.values_by_number[finding.likelihood]
.name)
print('Likelihood: {}'.format(likelihood))
else:
print('No findings.')
我还设置了以下 ENV 变量:
GOOGLE_APPLICATION_CREDENTIALS
当您不在 SSL 代理后面时,它可以毫无问题地运行。当我在代理后面工作时,我正在设置 3 个 ENV 变量:
REQUESTS_CA_BUNDLE
HTTP_PROXY
HTTPS_PROXY
通过这样的设置,其他 GCP 客户端 python 库可以在 SSL 代理后面正常工作,例如用于存储或 bigquery。
对于 DLP 客户端 python 库,我得到:
E0920 12:21:49.931000000 24852 src/core/tsi/ssl_transport_security.cc:1229] Handshake failed with fatal error SSL_ERROR_SSL: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed.
DEBUG:google.api_core.retry:Retrying due to 503 Connect Failed, sleeping 0.0s ...
E0920 12:21:50.927000000 24852 src/core/tsi/ssl_transport_security.cc:1229] Handshake failed with fatal error SSL_ERROR_SSL: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed.
DEBUG:google.api_core.retry:Retrying due to 503 Connect Failed, sleeping 0.0s ...
我没有在文档中找到解释该库是否作为一个 GCP 客户端库与代理一起工作以及如何配置它以与 SSL 代理一起工作。该库处于测试阶段,因此可能尚未实现。
好像跟CA证书和握手有关。 BigQuery 和存储客户端 python 库的相同 CA 没有问题。有什么想法吗?
最佳答案
您的代理正在执行 TLS 拦截
。这会导致 Google 库不信任您的代理在访问 Google API 端点时提供的 SSL 证书。这是一个中间人问题。
解决方案是绕过 Google API 的代理。在运行应用程序的 VPC 子网中,启用私有(private) Google 访问。这需要默认 VPC 路由规则仍然存在(或重新创建)。
[在下面评论后编辑]
我添加这条评论是为了吓唬蜂蜡。
TLS 拦截非常危险,如果阅读以下内容,任何合理的公司都不会实现它。
本例中的场景。我是负责公司代理的 IT 人员。公司已经实现了 TLS 拦截,我控制了代理。我无权访问我公司的 Google Cloud 资源。我很聪明,我非常了解 Google Cloud IAM 和 OAuth。我要黑掉我的公司,因为也许我没有得到加薪(发明你自己的理由)。
我等待一位拥有组织或项目所有者/编辑者级别权限的经理向 Google Cloud 进行身份验证。我的代理记录了 HTTPS header 、正文和所有指向 https://www.googleapis.com/oauth2/v4/token
和更多 URL 的响应。
也许代理在未实现可靠授权的情况下将日志存储在 Google Cloud Bucket 或 SAN 卷上。也许我只是一个发现代理日志文件随处可见或易于访问的软件工程师。
公司管理员登录到他的 Google 帐户。我捕获返回的 OAuth 访问 token 。我现在可以在接下来的 3,600 秒内模拟组织管理员。此外,我捕获了 OAuth 刷新 token 。我现在可以随时根据自己的意愿重新创建 OAuth 访问 token ,直到撤销刷新 token 为止,而对于大多数公司来说,他们永远不会这样做。
对于持怀疑态度的人,请研究我的 Golang 项目,该项目展示了如何将 OAuth 访问 token 和刷新 token 保存到用于验证的任何 Google 帐户的文件中。我可以将此文件带回家并在没有任何身份验证的情况下获得授权。此代码将在它过期时重新创建访问 token ,让我几乎永远可以访问这些凭据被授权的任何帐户。您的内部 IT 资源永远不会知道我正在您的公司网络之外执行此操作。
注意:Stackdriver Audit 日志记录可以捕获 IP 地址,但是,身份将是我窃取的凭据。为了隐藏我的 IP 地址,我会去星巴克或距离我家/工作几个小时车程的公共(public)图书馆,然后在那里做我的事。现在找出这个黑客的位置和对象。这会让法医专家感到胃灼热。
https://github.com/jhanley-com/google-cloud-shell-cli-go
注意:此问题不是 Google OAuth 或 Google Cloud 的问题。这是公司部署的安全问题示例(TLS 拦截)。这种技术风格适用于我所知道的几乎所有不使用 MFA 的身份验证系统。
[结束编辑]
关于python - 如何为 python 配置谷歌云平台数据丢失预防客户端库以在 SSL 代理后面工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58026566/
我完全不同意配置代理来检查我正在开发的应用程序的 HTTP(S) 流量。我试过运行 Fiddler2 和 Charles Web Proxy,它们都在 127.0.0.1:888 上运行,并使用以下参
我有一个 AWS 环境,其中有几个实例没有预安装 SSM 代理,也没有 key 对,有没有办法在不使用 SSH 登录我的实例的情况下安装 SSM 代理? 在此先感谢您的帮助! 最佳答案 没有。这是一个
在本教程中,您将借助示例了解 JavaScript 代理。 在 JavaScript 中,proxy(代理对象)用于包装对象并将各种操作重新定义到对象中,例如读取、插入、验证等。代理允许您向对
我有一个基于 Martini 的小型应用程序,但遇到了一个我无法解决的问题。 我想添加一个应用程序功能,允许用户从第三个服务器获取文件,并在 HTTP header 中进行一些更改。某种代理。这些文件
结构对比 讲实话,博主当初学习完整设计模式时,这三种设计模式单独摘哪一种都是十分清晰和明确的,但是随着模式种类的增加,在实际使用的时候竟然会出现恍惚,例如读开源代码时,遇到不以模式命名规范的代码时,
我正在尝试代理运行 ELK 的后端服务器。这是我的环境信息: root@proxy:~# root@proxy:~# cat /etc/*release DISTRIB_ID=Ubuntu DISTR
我需要为我的 java 应用程序编写一个代理,它在每个数组创建时执行一些特定的操作。到目前为止,我无法找到在此事件上运行我的代码的任何方法。 java.lang.instrument.ClassFil
PHP 代理如何工作? 我希望制作一个类似于其他 php 代理的小脚本 但是它实际上是如何工作的呢? 最佳答案 我正在考虑一个 PHP 代理,用于绕过 AJAX Sane Origin 策略。如果您需
我有一个 Electron 应用程序,试图通过该应用程序从同一网络调用url,但是出于安全考虑,我考虑了使用代理的想法。 function createWindow () { const mai
我有 1 台计算机,安装了 1 个网卡。网卡有 10 个 IP 地址分配给它。我在那里运行了一个 Windows 桌面应用程序。该应用程序基本上是一个调用 1 个特定网站的网络浏览器。 我想要实现的是
我想将 Burp 配置为我的 java 代码的代理,以查看请求和响应。Burp 作为 Web 浏览器之间的代理可以很好地工作,但它不适用于 Java 应用程序。 我已经在代码中添加了这样的行: Web
据我所知,在Spring AOP中,当我们想要拦截某些方法调用时,我们会配置一个具有与所需方法调用相匹配的切入点配置的Aspect。也就是说,我们在Aspect端配置拦截。 有没有一种方法可以完全从相
这可能是一个常见问题,但是:我有一个正在向 发出请求的应用程序elldmess.cz/api/... 但是这个api已经没有了。 现在我想要“东西”,即 catch 对 elldmess.cz/api
我正在尝试在 Android 中创建代理,但我必须使用套接字。我已经阅读了很多教程并提出了以下代码。不幸的是,浏览器似乎没有获得任何数据,一段时间后它显示标准网页,说网页不可用。可能是什么原因?感谢您
我在使用此代码时遇到了一些问题,具体取决于我使用的浏览器,有些 URL 在 IE 中显示正确,但在 Firefox 中显示为纯文本(例如 www.microsoft.es 在 IE 上看起来不错,但在
我正在尝试通过 urllib 获取一些 url 并通过我的代理进行 Mechanize 。 使用 mechanize 我尝试以下操作: from mechanize import Browser im
我安装了一个嵌入式设备(光伏转换器),它提供了一个正常的 http Web 界面(信息和设置)。该转换器具有用户身份验证,但只能通过 http 进行。出于安全考虑,我不想将服务器直接发布到互联网上。在
我正在搜索有关如何使用支持 HTTPS 的 Ruby 编写代理的一些示例。我有一个使用 Webricks HTTPProxyServer 实现的简单代理,但我注意到,HTTPS 流量只是隧道传输(它应
我的一位客户刚收到他选择的开发商订购的软件,让我看一下并准备托管程序。 这是一个 Java (jar) 应用程序,到目前为止一切顺利......但我看到了一些可疑的东西,软件每隔 60 分钟左右连接到
我试图在 C# 中创建一个 HTTPS 代理服务器。这里有人发布了解决方案: string host = "encrypted.google.com"; string
我是一名优秀的程序员,十分优秀!