我跑的npm install时候说found 33 vulnerabilities (2 low, 31 moderate)
run `npm audit fix` to fix them, or `npm audit` for details.
但是,npm audit fix产出up to date in 11s
fixed 0 of 33 vulnerabilities in 24653 scanned packages
33 vulnerabilities required manual review and could not be updated
这是否review意味着它不应由用户修复?
当我运行npm audit它时,给我一个表的列表,类似于Update to version 4.17.5 or later.
在此示例中,链接页面的修复部分说/node_modules/browser-sync/package.json.但是,/node_modules/lodash/lodash.json有以下几行:
????????????????????????????????????????????????????????????????????????????????
? Low ? Prototype Pollution ?
????????????????????????????????????????????????????????????????????????????????
? …Run Code Online (Sandbox Code Playgroud) Laravel v5.7.1
我有多个具有相同断言的测试,并且希望将它们移动到一个函数中并从测试中调用它。这是函数的示例:
private function admin_only($url, $method = 'GET', $data = []) {
// \Auth::logout();
$response = $this->json($method, $url, $data);
$response->assertStatus(401);
$response = $this->actingAs($this->user(),'api')->json($method, $url, $data);
$response->assertStatus(403);
$response = $this->actingAs($this->admin(),'api')->json($method, $url, $data);
$response->assertStatus(200);
}
Run Code Online (Sandbox Code Playgroud)
在这里,我首先检查未经身份验证的用户,一切都按预期工作,但是有一些函数,API 调用会切换某些状态,所以我想通过第二次调用函数来将其恢复:
$this->admin_only('/api/service/toggle-state', 'POST', $data);
$this->admin_only('/api/service/toggle-state', 'POST', $data);
Run Code Online (Sandbox Code Playgroud)
同一测试中的第二次调用会导致失败,因为第一次$this->json()用作管理员并返回成功代码。
这\Auth::logout()应该可以解决问题,但却引发错误BadMethodCallException: Method Illuminate\Auth\RequestGuard::logout does not exist.
“对第二次呼叫进行单独测试”、“无切换恢复”、“非管理员用户和访客使用相同的响应代码”等解决方案应该有效,但对我来说似乎是错误的。
我正在尝试编写一个包来使用。这是示例代码:
package redis
import (
"fmt"
"github.com/gomodule/redigo/redis"
"log"
"os"
)
var conn redis.Conn
func init() {
// code to set conn variable
}
func do(command string, args ...interface{}) (interface{}, error) {
init()
return conn.Do(command, args)
}
Run Code Online (Sandbox Code Playgroud)
这段代码不编译,编译器说undefined: init。当我改变init()到Init()它的工作原理,但我不希望它是封装外提供。无论我在哪里读到这个问题,它都说从另一个包调用未导出的函数,但在这里我从同一个包调用它。
此外,Goland IDE 将函数调用标记为unresolved reference并建议创建它。但是当我这样做时(通过 IDE 本身),它仍然没有看到它。