Checkmarx 为我的 Controller 类中的以下方法提供了 XSS 漏洞。\n具体来说:此元素\xe2\x80\x99s 值(ResultsVO)然后在没有经过适当清理或验证的情况下流经代码,并最终在方法中显示给用户:
\n\n @RequestMapping(value = "/getresults", method = RequestMethod.POST, produces = "application/json")\n @ResponseBody\n public ResultsVO getConfigResults(@RequestBody ResultsVO resultsVO, HttpServletRequest request)\n throws OverrideApplicationException {\n String loggedUserId = request.getHeader("USER");\n return resultsService.getConfigResults(resultsVO, loggedUserId);\n }\nRun Code Online (Sandbox Code Playgroud)\n\nResultsVO 对象有很多 String 属性,我只是想知道是否有一种优雅的方法对它们进行编码以防止此漏洞。
\n我最近被锁定了我的 UniFi 控制器(本地安装),并且我关闭了远程访问。控制器安装在 Windows 10 (20H2) VM 上。我可以很好地进入虚拟机,但是当我尝试登录本地主机网站时,它与我认为设置的密码不同。
有人知道如何做到这一点吗?
我的网站上有购物车功能。
我在两个不同的页面(cart.html.twig 和 home.html.twig)上显示购物车,并且我可以修改这两个页面上的购物车。
当我想用按钮增加产品+1时,我被重定向到单一路线。
如果用户在主页上增加产品,我希望他被重定向到主页,如果他在购物车页面上增加产品,我希望他被重定向到购物车页面,我想如何做到这一点,我我有点失落。
有没有办法重定向到上一页?
有代码:
class CartService {
protected $session;
protected $productRepository;
public function __construct(SessionInterface $session, ProductRepository $productRepository){
$this->session = $session;
$this->productRepository = $productRepository;
}
public function add(int $id){
$cart = $this->session->get('cart', []);
if(isset($cart[$id])){
$cart[$id]++;
} else {
$cart[$id] = 1;
}
$this->session->set('cart', $cart);
}
public function remove(int $id) {
$cart = $this->session->get('cart', []);
if(isset($cart[$id])){
if($cart[$id] > 1){
$cart[$id]--;
} else {
unset($cart[$id]);
}
}
$this->session->set('cart', $cart);
}
public function delete(int $id){
$cart …Run Code Online (Sandbox Code Playgroud) 我有一个拦截器,我需要添加代码其他部分所需的自定义标头
public class KeyTaskInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
if (// a custom condition) {
request. // set custom header key ... `KeyCode`
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
问题是前端不会发送名为“ KeyCode”的自定义标头,并且我无法更改期望此标头的控制器的实现,因此我必须找到一种方法,在发送之前根据 preHandle 方法的请求添加自定义标头向控制器发出请求。有人能帮助我吗?
我之前问了一个问题,引起了一些很好的回应.
在那里给出的一些建议的背面,我尝试移动以下控制器逻辑
if params[:concept][:consulted_legal] == 0 && params[:concept][:consulted_marketing] == 1
@concept.attributes = {:status => 'Awaiting Compliance Approval'}
elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_legal] == 1
@concept.attributes = {:status => 'Awaiting Marketing Approval'}
elsif params[:concept][:consulted_marketing] == 0 && params[:concept][:consulted_legal] == 0
@concept.attributes = {:status => 'Awaiting Marketing & Legal Approval'}
else
@concept.attributes = {:status => 'Pending Approval'}
end
Run Code Online (Sandbox Code Playgroud)
进入模型,如下:
def set_status
if status.blank?
if (consulted_legal == true) && (consulted_marketing == true)
status = "Pending Approval"
elsif (consulted_legal == true) && …Run Code Online (Sandbox Code Playgroud) 我在Rails上有一个动作,但我希望继续从另一个动作中进行处理.我的代码看起来像这样:
send(new_action) #call the new_action method
action_name = new_action #change the controller.action_name
render :action => new_action #inform the view that we're in new_action
Run Code Online (Sandbox Code Playgroud)
这工作,但action_name - 虽然它从ActionController实例中更改 - 在从视图中检索时被重置
controller.action_name
Run Code Online (Sandbox Code Playgroud)
有没有办法设置它并让它坚持下去?
编辑:我找到了另一个不涉及这个问题的解决方案,就在这里.谢谢!
这是我的方法
[AcceptVerbs(HttpVerbs.Post)]
public void SaveImage(FormCollection formValues)
{
byte[] contents = Convert.FromBase64String(Request.Form["file"]);
System.IO.File.WriteAllBytes(Server.MapPath(Request.Form["name"]), contents);
}
Run Code Online (Sandbox Code Playgroud)
它将从此actionscript方法发布到:
public function encodeAndSave(e:MouseEvent = null):void
{
var date:Date = new Date();
var by:ByteArray = PNGEnc.encode(canvas.main_bdata);
var req:URLRequest = new URLRequest(server_path+"Home/SaveImage");
var params:URLVariables = new URLVariables();
params.file = Base64.encodeByteArray(by);
params.name = "MyImage.png";
req.method = URLRequestMethod.POST;
req.data = params;
var ldr:URLLoader = new URLLoader(req);
ldr.addEventListener(Event.COMPLETE, complete);
ldr.load(req);
function complete(e:Event):void
{
navigateToURL(new URLRequest("?" + Math.random()), "_self");
}
}
Run Code Online (Sandbox Code Playgroud)
但是当encodeAndSave方法运行时,没有文件保存到服务器......
有谁知道如何判断SaveImage方法是否已运行?另外,当我在地址栏中键入:http: //www.mysite.com/Home/SaveImage时,它会显示"无法找到资源".
任何人都有任何想法,为什么它会这样做或我能做些什么来试图找出它?
如果您需要更多信息,请告诉我,我会更新我的问题.
谢谢,
马特
我在Codeigniter中测试控制器时遇到了困难:我使用Toast但是当我调用Home Controller类时,我得到一个异常,即"db"未定义.有谁知道如何测试这个1-1?
谢谢
class Home_tests extends Toast {
function __construct() {
parent::__construct(__FILE__);
// Load any models, libraries etc. you need here
}
function test_select_user() {
$controller = new Home();
$controller->getDbUser('foo@gmail.com','password');
assert($query->num_rows() == 0 );
}
}
Run Code Online (Sandbox Code Playgroud) 我正在开发Grails应用程序.我现在有大约20个控制器,还会有更多.有没有办法在功能包中对控制器进行分组?我希望有类似的东西:
grails-app/administration/<controller classes>
grails-app/usercontent/<controller classes>
grails-app/publiccontent/<controller classes>
Run Code Online (Sandbox Code Playgroud)
如果包不会出现在URL中,那将是最好的.
我需要将默认的CakePHP主页/或(/ pages/home)重定向到我尝试过的/ users/dashboard页面
Router::connect('/', array('controller' => 'users', 'action' => 'dashboard'));
Run Code Online (Sandbox Code Playgroud)
和
Router::connect('/pages/home', array('controller' => 'users', 'action' => 'dashboard'));
Run Code Online (Sandbox Code Playgroud)
但两者都不起作用
controller ×10
java ×2
asp.net-mvc ×1
cakephp ×1
cart ×1
checkmarx ×1
codeigniter ×1
file-io ×1
grails ×1
http-post ×1
jvm ×1
localhost ×1
login ×1
model ×1
owasp ×1
passwords ×1
php ×1
redirect ×1
refactoring ×1
reset ×1
routes ×1
ruby ×1
sanitization ×1
spring ×1
spring-boot ×1
symfony ×1
testing ×1