我在以自动方式禁用 CSRF 保护时遇到问题。我想在 Jenkins Master 启动之前使用 groovy init 脚本或仅在属性文件中禁用。我不确定为什么我会遇到面包屑问题,我认为这与 K8S/AWS 中暴露的 LB 有关。我正在使用 AWS ELB 来公开 pod 并在面包屑中导致 csrf 异常,并且有时当我去管理 Jenkins 时我也会收到反向代理警告。
我研究了它说我可以启用扩展代理兼容性或禁用 CSRF 检查的问题。我还没有找到它们所在的 groovy 或配置文件。
我当前的 groovy init 脚本如下:
import hudson.security.csrf.DefaultCrumbIssuer
import jenkins.model.Jenkins
def j = Jenkins.instance;
j.setCrumbIssuer(null); // I've also tried setting a new crumb issuer here as well.
j.save();
System.setProperty("hudson.security.csrf.CrumbFilter", "false");
System.setProperty("hudson.security.csrf", "false");
System.setProperty("hudson.security.csrf.GlobalCrumbIssuerConfiguration", "false");
Run Code Online (Sandbox Code Playgroud)
我似乎无法找到有关如何禁用此属性或启用启用代理兼容性属性的参考。
Crumb Algorithm
Default Crumb Issuer
Enable proxy compatibility
Run Code Online (Sandbox Code Playgroud)
我在单击应用时拦截了配置请求,并且传递的 json 负载似乎设置为
"hudson-security-csrf-GlobalCrumbIssuerConfiguration": {
"csrf": {
"issuer": {
"value": "0",
"stapler-class": …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 python 中使用 sqllite 自动增量功能。从我在线阅读的内容来看,您只需要指定 ID INTEGER PRIMARY KEY AUTOINCREMENT 或其他任何内容,然后插入而不指定 id 列。然而,当我的脚本去插入一个值时,它给我一个错误,关于只指定 3 列而不是 4 意味着它正在寻找我指定 id 列,所以我对如何进行自动增量有点困惑。
cur.execute("""CREATE TABLE ROOMS(ID INTEGER PRIMARY KEY AUTOINCREMENT,
NAME TEXT,
TAGLINE TEXT,
DATE DATE)""")
cur.execute("""INSERT INTO ROOMS
VALUES(?,?,?)""" , ( name, tagline, str(creation_date) ))
conn.commit()
Run Code Online (Sandbox Code Playgroud)
表 ROOMS 有 4 列,但提供了 3 个值
完整代码
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright [current year] the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not …Run Code Online (Sandbox Code Playgroud) 以下是显示问题的YouTube视频:https://www.youtube.com/watch?v = znzLQSYlsKM.
我提供了视频描述中涉及的所有代码的链接.
我正在使用js库将影响应用于图像.然后我触发一个事件,为用户提供下载链接,并动态创建一个带有base64的表单元素.然后我将它传递给php文件并将其保存到文件夹中.您可以下载的图像具有应用于它的效果,但保存的图像将保存而不起作用.问题是它们都是完全相同的文件.
JS代码:
function showDownload(canvas){
//this is how i send it to my main page and use ajax script to upload to the php file.
var url = canvas.toDataURL("image/png;base64;");
$('<input/>').attr({
type: 'hidden', id: 'fileroast', name: 'fileroast', value: url
}).appendTo('#output');
// this is how i link the download file
downloadImage.off('click').click(function(){
var url = canvas.toDataURL("image/png;base64;");
downloadImage.attr('href', url);
}).fadeIn();
}
Run Code Online (Sandbox Code Playgroud)
过滤代码:
filters.click(function(e){
e.preventDefault();
var f = $(this);
if(f.is('.active')){
// Apply filters only once
return false;
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试删除一个实例化的光子网络对象,一旦它被碰撞,但是即使我将它设置为对象并且错误返回正确的对象它由于某种原因无法删除它,我可以不明白为什么在这里。这里有错误:
Failed to 'network-remove' GameObject because it is missing a valid
InstantiationId on view: View (0)1 on SUV (scene). Not Destroying GameObject
or PhotonViews! UnityEngine.Debug:LogError(Object)
NetworkingPeer:RemoveInstantiatedGO(GameObject, Boolean) (at Assets/Photon
Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2499) PhotonNetwork:Destroy(GameObject)
(at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2259)
BulletScript:OnCollisionEnter(Collision) (at Assets/Prefab/Resources/Scripts
/BulletScript.cs:29)
public Transform explosionPrefab;
private Transform explosion;
public GameObject bullet;
void OnCollisionEnter(Collision col) {
if(col.gameObject.name == "Player"){
PhotonNetwork.Destroy (col.gameObject);
Instantiate(explosionPrefab, col.transform.position, col.transform.rotation);
}
if (col.gameObject.name == "SUV") {
PhotonNetwork.Destroy (col.gameObject);
Instantiate(explosionPrefab, col.transform.position, col.transform.rotation);
}
PhotonNetwork.Destroy (bullet);
Instantiate(explosionPrefab, bullet.transform.position, bullet.transform.rotation);
}
Run Code Online (Sandbox Code Playgroud) 我有一个 ajax 请求,将文件发送到 django,它说 csrf 令牌丢失,但我复制了其他正在运行的 ajax 请求。我确信这与尝试传递要上传的文件有关。
我收到 403 和 csrf 缺失返回。
基本.html
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.2.js'></script>
<script type="text/javascript">
$(document).ready(function() {
$("#create_token").click(function() {
var username = document.getElementById("username").value;
$.ajax({
url : "/gettoken/",
type : "POST",
dataType: "json",
data : {
csrfmiddlewaretoken: '{{ csrf_token }}',
create_token: 'create_token',
username: username,
},
success : function(json) {
document.getElementById('output').innerHTML = ('Token: ' + json['token']);
},
error : function(xhr,errmsg,err) {
console.log(xhr.status + ": " + xhr.responseText);
document.getElementById('output').innerHTML = "Token:" + " Request Failed.";
}
});
return false; …Run Code Online (Sandbox Code Playgroud) 我正在尝试将图像过滤器应用于图像,并在每次单击过滤器时重新创建文件元素.因此,这将是伪代码.它仍然说文件字段为空,我不知道为什么.
我正在尝试将文件传递给处理上传的PHP脚本,但我不知道如何在脚本中执行此操作,因为我的javascript技能不够好..
HTML
<div id="uploadPic" class="modal fade" >
<form method="post" id="fileinfo" name="fileinfo" onsubmit="return submitForm();">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header" style="background:#f3f3f3;">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" style="color:black;">Choose picture to upload as profile pic.</h4>
</div>
<div class="modal-body">
<div id="filterContainer" style='width:400px;'>
<ul id="filters" style='width:400px;'>
<li> <a href="#" id="normal">Normal</a> </li>
<li> <a href="#" id="vintage">Vintage</a> </li>
<li> <a href="#" id="lomo">Lomo</a> </li>
<li> <a href="#" id="clarity">Clarity</a> </li>
<li> <a href="#" id="sinCity">Sin City</a> </li>
<li> <a href="#" id="sunrise">Sunrise</a> </li>
<li> <a href="#" id="crossProcess">Cross Process</a> …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用入口进行 TCP/UDP 端口转发。
按照文档:https://kubernetes.github.io/ingress-nginx/user-guide/exusing-tcp-udp-services/
它说设置:--tcp-services-configmap但没有告诉你在哪里设置它。我认为它是命令行参数。然后我用谷歌搜索了 nginx-ingress 的命令行参数列表
https://kubernetes.github.io/ingress-nginx/user-guide/cli-arguments/
在这里你可以清楚地看到它的控制器的参数:
--tcp-services-configmap 包含要公开的 TCP 服务定义的 ConfigMap 的名称。图中的键表示要使用的外部端口。该值是对服务的引用,格式为“namespace/name:port”,其中“port”可以是端口号或名称。TCP 端口 80 和 443 被控制器保留用于服务 HTTP 流量。
第一个问题:如何动态添加到 nginx-ingress helm 图表的容器参数中,我在任何地方都没有看到该记录?
第二个问题:使用当前版本的 nginx-ingress 设置此值的正确方法是什么,因为设置命令行参数会使容器启动失败,因为二进制文件没有该参数选项。
在默认的 Helm Chart Values.yaml 中,有一些关于为 tcp-services 设置 configmap 的命名空间的选项,但考虑到文档说我必须将其设置为参数,但该参数启动失败,我不知道你如何实际上设置了这个。
https://github.com/kubernetes/ingress-nginx/blob/main/charts/ingress-nginx/values.yaml
我手动编辑了部署并在容器参数上设置了标志:
- args:
- -nginx-plus=false
- -nginx-reload-timeout=60000
- -enable-app-protect=false
- -nginx-configmaps=$(POD_NAMESPACE)/emoney-nginx-controller-nginx-ingress
- -default-server-tls-secret=$(POD_NAMESPACE)/emoney-nginx-controller-nginx-ingress-default-server-tls
- -ingress-class=emoney-ingress
- -health-status=false
- -health-status-uri=/nginx-health
- -tcp-services-configmap=emoney-node/tcp-services-configmap
- -nginx-debug=false
- -v=1
- -nginx-status=true
- -nginx-status-port=8080
- -nginx-status-allow-cidrs=127.0.0.1
- -report-ingress-status
- -external-service=emoney-nginx-controller-nginx-ingress
- …Run Code Online (Sandbox Code Playgroud) 我不完全确定为什么我会收到字典键错误.我正在尝试使用=符号创建一个多级别的dict,并在指标上获得关键错误,但不会在前两个上.
doc['timestamp']
Run Code Online (Sandbox Code Playgroud)
和
doc['instance_id']
Run Code Online (Sandbox Code Playgroud)
两者都工作正常,但当它达到指标时,它给我一个指标关键错误.我不完全确定为什么.
doc = {}
doc['timestamp'] = datetime.now()
#doc['instance_id'] = get_cloud_app_name()
doc['instance_id'] = "MyMac"
cpu_dict_returned = get_cpu_info()
doc['metrics']['cpu_usage']['user_cpu'] = cpu_dict_returned['user_cpu']
doc['metrics']["cpu_usage"]['system_cpu'] = cpu_dict_returned['system_cpu']
doc['metrics']["cpu_usage"]['idle_cpu'] = cpu_dict_returned['idle_cpu']
doc['metrics']["cpu_usage"]['cpu_count'] = cpu_dict_returned['cpu_count']
Run Code Online (Sandbox Code Playgroud) jquery ×3
python ×3
canvas ×2
javascript ×2
php ×2
python-2.7 ×2
ajax ×1
bottle ×1
c# ×1
dictionary ×1
django ×1
groovy ×1
html ×1
html5 ×1
jenkins ×1
kubernetes ×1
photon ×1
sqlite ×1