小编Ome*_*oni的帖子

使用TLS保护Kubernetes服务

我有一个内部应用程序,只有集群IP服务才能将其暴露给集群上的其他应用程序.其他服务通过它的DNS(serviceName-namespace.svc.cluster.local)访问此应用程序.此应用程序处理敏感数据,因此尽管所有通信都在集群内部,但我希望使用TLS来保护与此应用程序的通信.

我的问题是 - 如何在服务上启用TLS?是否存在某些东西或应该在应用程序代码上处理它?此外,是否已经可以在群集上使用可以为其签名的CA .svc.cluster.local

为了澄清,我知道我可以使用入口来达到这个目的.唯一的问题是只保留此服务内部 - 因此只有集群内的服务才能访问它.

谢谢,奥梅尔

ssl kubernetes tls1.2 kubernetes-security kubernetes-service

10
推荐指数
1
解决办法
2732
查看次数

Jacoco代码覆盖项目的多种口味和模块

正如标题所说,这就是问题所在.我有一个带有模块的android风格的应用程序.该应用程序在android-studio和TeamCity服务器中使用gradle编译.我们有自定义任务来创建看起来像这样的代码覆盖:

task codeCoverageReport(type: JacocoReport) {
// Gather execution data from all subprojects
executionData fileTree(project.rootDir.absolutePath).include("**/build/jacoco/*.exec")

//Build class & source dirs
def classExcludes =['**/R.class',
                    '**/R$*.class',
        '**/BuildConfig.class',
        '**/*$InjectAdapter*.class',
        '**/*$ModuleAdapter*.class',
        '**/*$ViewInjector*.class']
sourceDirectories = files();
classDirectories = files();
subprojects.each{
    sourceDirectories += files(it.projectDir.absolutePath + '/src/main/java')
    def path1 = it.buildDir.absolutePath + '/intermediates/classes/debug'
    def path2 = it.buildDir.absolutePath + '/classes/main'
    classDirectories += fileTree(dir: path1, excludes: classExcludes, includes: ['**/*.class'])
    classDirectories += fileTree(dir: path2, excludes: classExcludes, includes: ['**/*.class'])
}

reports {
    xml.enabled true
    html.enabled true
    html.destination "${buildDir}/reports/jacoco"
    csv.enabled false
}

doFirst …
Run Code Online (Sandbox Code Playgroud)

android module gradle jacoco android-productflavors

7
推荐指数
0
解决办法
705
查看次数

使用 JQ 展平嵌套 JSON 数组

我有一个以下格式的 JSON:

{
  "@version": "2.7.0",
  "site": {
    "@name": "http://api:9999",
    "@ssl": "false",
    "alerts": [
      {
        "pluginid": "10094",
        "desc": "<p>Base64 encoded data was disclosed by the application/web server<\/p>",
        "instances": [
          {
            "uri": "http://api:9999",
            "method": "POST",
            "evidence": "DxyPP_YQ6qdWA_Kw_ZLgYilIkXCz93Xs1CeJPvg"
          },
          {
            "uri": "http://api:9999",
            "method": "POST",
            "evidence": "eyJuYmYiOjE121lMWF1siSG9tZUFwcCJdfQ"
          }
        ],
        "count": "37"
      }
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

我想展平内部数组 -.site.alerts.instances以获得以下 JSON:

{
    "@name": "http://api:9999",
    "@ssl": "false",
    "alerts": [
      {
        "pluginid": "10094",
        "desc": "<p>Base64 encoded data was disclosed by the application/web server<\/p>",
        "uri": "http://api:9999",
        "method": "POST", …
Run Code Online (Sandbox Code Playgroud)

json jq

7
推荐指数
1
解决办法
8519
查看次数

如何在 Dockerfile 中正确缓存 C# dotnet 核心包?

我正在尝试构建高效dockerfile,因此仅在删除/添加/更新包时才会触发包还原。这是我尝试过的(基于官方示例):

FROM microsoft/dotnet:2.0-sdk-stretch AS build-env
WORKDIR /app

# Copy csproj and restore as distinct layers
COPY ./src/myapp.csproj ./
RUN dotnet restore && \
    dotnet add package ILLink.Tasks -v 0.1.4-preview-981901 -s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

# Copy everything else and build
COPY ./src ./
RUN dotnet publish -c Release -o out -r linux-x64

# Build runtime image
FROM microsoft/dotnet:2.0-runtime-deps
RUN useradd -d /home/dotnet -ms /bin/bash dotnet
USER dotnet
WORKDIR /home/dotnet/app
ENV ASPNETCORE_URLS=http://+:9999
COPY --from=build-env /app/out ./
ENTRYPOINT ["./myapp"]
Run Code Online (Sandbox Code Playgroud)

我正在复制csprog …

c# docker .net-core docker-build

6
推荐指数
1
解决办法
1824
查看次数

Android KeyStore - 键并不总是持久存在

在我的应用程序中,我们使用RSA密钥,该应用程序在第一次启动时生成(使用Android密钥库).由于未知原因,应用程序无法从某些设备上的密钥存储区检索密钥.我检查了日志,我找不到这个bug与特定操作系统版本或特定设备模型之间的关联.此外,我确信应用程序只在创建密钥后才尝试读取它.所以 - 我的问题是:据我所知,android密钥库应该是持久的.什么会导致这样的错误?

Bellow是相关的代码示例.

密钥生成:

try {
        KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", keyStore.getProvider());

        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M){
            KeyGenParameterSpec spec;
            spec = new KeyGenParameterSpec.Builder(alias, KeyProperties.PURPOSE_DECRYPT | KeyProperties.PURPOSE_ENCRYPT| KeyProperties.PURPOSE_SIGN| KeyProperties.PURPOSE_VERIFY)
                    .setDigests(KeyProperties.DIGEST_SHA256, KeyProperties.DIGEST_SHA512)
                    .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_RSA_PKCS1)
                    .setSignaturePaddings(KeyProperties.SIGNATURE_PADDING_RSA_PKCS1)
                    .setKeySize(2048)
                    .build();

            generator.initialize(spec);
        } else {
            Calendar start = new GregorianCalendar();
            Calendar end = new GregorianCalendar();
            end.add(Calendar.YEAR, 500);

            KeyPairGeneratorSpec spec = new KeyPairGeneratorSpec.Builder(context)
                    .setAlias(alias)
                    .setSubject(new X500Principal("CN="+ subject))
                    .setSerialNumber(BigInteger.valueOf(new Random().nextInt(Integer.MAX_VALUE)))
                    .setStartDate(start.getTime())
                    .setEndDate(end.getTime())
                    .setKeySize(2048)
                    .build();

            generator.initialize(spec);
        }
        return generator.generateKeyPair();
    } catch (Exception e) {
        logger.warn("Failed to create private key in store", …
Run Code Online (Sandbox Code Playgroud)

android android-keystore

5
推荐指数
1
解决办法
1407
查看次数

Azure AD:使用设备代码请求令牌失败,出现401

我正在尝试将Azure AD与设备代码流一起使用。我创建了一个应用程序,并尝试使用此客户端ID请求代码。编码请求成功,并且我能够批准登录。但是,当我尝试使用设备代码请求令牌时,请求失败,并出现以下错误:

AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'.
Run Code Online (Sandbox Code Playgroud)

据我所知,此流程不需要任何凭据,因此我不确定为什么会发生此错误。我能够使用不同的语言和不同的Adal库(NodeJS,C#)以及Postman来复制它。因此,我很确定这不是特定库中的错误。可能是我配置错误的内容-尽管我不清楚是什么。你能帮我解决这个问题吗?

oauth-2.0 azure-active-directory adal

3
推荐指数
1
解决办法
347
查看次数