小编Pra*_*vin的帖子

如何将用户例外添加到 git 保护分支中的“合并前需要拉取请求审查”选项?

我正在尝试使用lerna publish来管理我团队中的包发布。所以 lerna 在每次发布结束时所做的是,它会package.json改变文件中的版本并在执行发布的分支中提交这些更改。

但是在 master 中,我需要"Require pull request reviews before merging"处于活动状态,因为它是受保护的分支。在合并之前需要拉取请求审查

我的问题不在于发布,因为 lerna 发布了包。但是 circle-ci 失败并出现此错误:

remote: error: GH006: Protected branch update failed for refs/heads/publish-test.
remote: error: At least 1 approving review is required by reviewers with write access.
To github.com:username/repo.git
 ! [remote rejected] publish-test -> publish-test (protected branch hook declined)
Run Code Online (Sandbox Code Playgroud)

我尝试启用"Restrict who can push to matching branches"选项以允许用户在 master 中提交(我们使用 bot 用户进行 devops 提交)。限制谁可以推送到匹配的分支

有没有办法向选项添加用户异常"Require pull request reviews before merging" …

github circleci

23
推荐指数
1
解决办法
2366
查看次数

如何使用预签名网址将对象放入亚马逊s3?

我正在尝试使用签名的URL将图像上传到s3存储桶.以下是我的保管政策:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam::12345678:user/myuser",
                    "arn:aws:iam::12345678:root"
                ]
            },
        "Action": [
                "s3:List*",
                "s3:Put*",
                "s3:Get*"
            ],
            "Resource": [
                "arn:aws:s3:::myBucket",
                "arn:aws:s3:::myBucket/*"
            ]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我从服务器生成签名的URL如下:

var aws = require('aws-sdk');
aws.config = {
    accessKeyId: myAccessKeyId,
    secretAccessKey: mySecretAccessKey
};

var s3 = new aws.s3();
s3.getSignedUrl('putObject', {
    Bucket: 'myBucket',
    Expires: 60*60,
    key: 'myKey'
}, function (err, url) {
    console.log(url);
});
Run Code Online (Sandbox Code Playgroud)

我得到了网址.但是当我尝试放置一个对象时,我收到以下错误:

<Error>
    <Code>AccessDenied</Code>
    <Message>Access Denied</Message>
    <RequestId>FXXXXXXXXX</RequestId>
    <HostId>fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX</HostId>
</Error>
Run Code Online (Sandbox Code Playgroud)

更新1

这是myuser的政策:

{
  "Version": "2012-10-17",
  "Statement": …
Run Code Online (Sandbox Code Playgroud)

javascript amazon-s3 amazon-web-services node.js pre-signed-url

22
推荐指数
2
解决办法
2万
查看次数

如何在jruby9.1.2.0中使用gpg加密来加密文件?

我试图使用gpg加密加密文件,然后在我的jruby项目中发送它.但是我找不到足够的资源.我尝试使用ruby-gpgme,但jruby不支持C库.我试过阅读Bouncy Castle,但我被课程文档所震撼,并没有找到加密文件的简单文章.

Vivek在这个问题上的答案接近我的解决方案,但只有解密文件的解决方案.我目前正在关注这篇文章并试图在jruby中连接java代码无济于事.我认为encryptFile功能是我需要的,如下所示:

public static void encryptFile(
        OutputStream out,
        String fileName,
        PGPPublicKey encKey,
        boolean armor,
        boolean withIntegrityCheck)
        throws IOException, NoSuchProviderException, PGPException
    {
        Security.addProvider(new BouncyCastleProvider());

        if (armor) {
            out = new ArmoredOutputStream(out);
        }

        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
        PGPCompressedDataGenerator comData = new PGPCompressedDataGenerator(PGPCompressedData.ZIP);

        PGPUtil.writeFileToLiteralData(
                comData.open(bOut),
                PGPLiteralData.BINARY,
                new File(fileName) );

        comData.close();

        BcPGPDataEncryptorBuilder dataEncryptor = new BcPGPDataEncryptorBuilder(PGPEncryptedData.TRIPLE_DES);
        dataEncryptor.setWithIntegrityPacket(withIntegrityCheck);
        dataEncryptor.setSecureRandom(new SecureRandom());

        PGPEncryptedDataGenerator encryptedDataGenerator = new PGPEncryptedDataGenerator(dataEncryptor);
        encryptedDataGenerator.addMethod(new BcPublicKeyKeyEncryptionMethodGenerator(encKey));

        byte[] bytes = bOut.toByteArray();
        OutputStream cOut …
Run Code Online (Sandbox Code Playgroud)

java encryption bouncycastle ruby-on-rails openpgp

11
推荐指数
1
解决办法
575
查看次数

无法获得当前路线.$ location.path()返回空.

我现在在/addDoc,我想要我现在的路线.这是我的控制器:

app.controller('DocRegistrationController',[ '$http', '$scope', '$upload', '$location', function($http, $scope, $upload, $location){
$scope.validation=function(){
   alert($location.path());
}
    }
Run Code Online (Sandbox Code Playgroud)

但它返回空.我不想硬编码所有的路线.我究竟做错了什么?

angularjs

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

为什么compareSync不需要盐串?

我正在尝试使用bcryptjs生成用户密码的哈希值.但是我在一件事情上有点困惑.

按照惯例,根据这一条款,我们需要:

  • 保持我们的密码哈希值相对较长且独特,
  • 使用此盐对用户密码进行哈希处理
  • 存储盐渍哈希密码和盐

因此,当我们在验证用户时比较哈希时,我们将存储的盐附加到用户输入的密码,并将其与来自数据库的哈希进行比较.

然而,使用hashSync和compareSync bcryptjs如下:

//hashSync to generate hash
var bcrypt = require('bcryptjs');
var password = "abc";
var hash = bcrypt.hashSync( <some string>, < integer length of salt>) // the salt of mentioned length(4-31) is self-generated which is random and fairly unique

//compareSYnc to compare hash
var testString="abc";
console.log(bcrypt.compareSync(testString, hash)) // compares with previously generated hash returns "true" in this case.
Run Code Online (Sandbox Code Playgroud)

我感到困惑的是,如果我们在验证时不需要盐,那么产生它的意义何在?compareSync返回时true无需访问salt.所以它不会让相对较小的密码容易遭受暴力攻击吗?无论盐的大小如何,以下所有内容都返回true:

console.log(bcrypt.compareSync("abc", bcrypt.hashSync("abc"))); // consoles true. by default, if …
Run Code Online (Sandbox Code Playgroud)

hash salt bcrypt saltedhash node.js

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

我如何在玩笑中使用 --changedSince 和 --onlyChanged ?

我想用changedSinceonlyChanged标志开玩笑。我更改了许多测试以及测试所依赖的文件。根据 jest cli 标志的文档:

changedSince:运行与自提供分支以来的更改相关的测试。如果当前分支与给定分支有分歧,则只会测试本地所做的更改。

onlyChanged : 别名 -o。尝试根据当前存储库中已更改的文件来确定要运行的测试。仅当您目前在 git/hg 存储库中运行测试并且需要静态依赖关系图(即没有动态需要)时才有效。

但是当我运行jest --changedSince=masterjest --onlyChanged它运行 0 个测试时,根本没有在终端中提供任何内容。

jest --listTests列出所有测试。但是,当我运行jest --listTests --changedSince=masteror 时jest --listTests --onlyChanged,它没有列出任何测试。

git testing unit-testing jestjs

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

使用gulp设置本地Web服务器

我来自笨拙的背景.设置Web服务器就像这样简单grunt connect.

我会将以下代码放在我的grunt文件中并运行grunt connect:

grunt.initConfig({
        // fire up the local server
        connect: {
            server: {
                options: {
                    port: 9778, //port to host on
                    livereload: 35729,
                    hostname: '0.0.0.0', //the hostname
                    base: 'out/' //the relative path from grunt file to base folder of web app
                }
            }
        }
    });

grunt.loadNpmTasks('grunt-contrib-connect');
Run Code Online (Sandbox Code Playgroud)

我的情况发生了变化,因为我不得不迁移到gulp.但我不能让它干涸.可能是因为我的背景.我正在使用gulp-webserver.并添加了我的gulp文件如下:

gulp.task('serve', function() {
  gulp.src('app')
    .pipe(webserver({
      path:'dist',
      port:'9090',
      livereload: true,
      directoryListing: true,
      open: true
    }));
});
Run Code Online (Sandbox Code Playgroud)

当我导航到时localhost:9090,我收到了回复:cannot GET /

我究竟做错了什么?不是gulp文件的路径相对路径?我应该传递给gulp.src谁?如果有人能给我一个关于哪里看的话,这将是一个很大的帮助.

编辑1 …

webserver gulp

4
推荐指数
1
解决办法
2万
查看次数

如何在 useEffect 中测试具有异步状态更新的钩子?

我有一个简单的钩子,可以获取值并将其设置为选项,如下所示:

import Fuse from 'fuse.js'
import React from 'react'

// prefetches options and uses fuzzy search to search on that option
// instead of fetching on each keystroke
export function usePrefetchedOptions<T extends {}>(fetcher: () => Promise<T[]>) {
  const [options, setOptions] = React.useState<T[]>([])
  React.useEffect(() => {
    // fetch options initially
    const optionsFetcher = async () => {
      try {
        const data = await fetcher()
        setOptions(data)
      } catch (err) {
        errorSnack(err)
      }
    }
    optionsFetcher()
  }, [])
  // const fuseOptions = {
  // …
Run Code Online (Sandbox Code Playgroud)

testing reactjs react-testing-library react-hooks-testing-library

2
推荐指数
1
解决办法
1万
查看次数