code
stringlengths
41
2.04k
label_name
stringclasses
2 values
label
int64
0
1
def show_unit_extensions(request, course_id): """ Shows all of the students which have due date extensions for the given unit. """ course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(course_id)) unit = find_unit(course, request.GET.get('url')) return JsonResponse(dump_module...
CWE-352
0
def test_rescore_problem_single_from_uname(self, act): """ Test rescoring of a single student. """ url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, ...
CWE-352
0
def rescore_problem(request, course_id): """ Starts a background process a students attempts counter. Optionally deletes student state for a problem. Limited to instructor access. Takes either of the following query paremeters - problem_to_reset is a urlname of a problem - unique_studen...
CWE-352
0
def test_post_broken_body(): response = client.post("/items/", data={"name": "Foo", "price": 50.5}) assert response.status_code == 422, response.text assert response.json() == { "detail": [ { "ctx": { "colno": 1, "doc": "name=Foo&pr...
CWE-352
0
def test_certificates_features_group_by_mode(self): """ Test for certificate csv features against mode. Certificates should be group by 'mode' in reponse. """ url = reverse('get_issued_certificates', kwargs={'course_id': unicode(self.course.id)}) # firstly generating download...
CWE-352
0
def test_list_email_with_no_successes(self, task_history_request): task_info = FakeContentTask(0, 0, 10, 'expected') email = FakeEmail(0) email_info = FakeEmailInfo(email, 0, 10) task_history_request.return_value = [task_info] url = reverse('list_email_content', kwargs={'cour...
CWE-352
0
def get_problem_responses(request, course_id): """ Initiate generation of a CSV file containing all student answers to a given problem. Responds with JSON {"status": "... status message ..."} if initiation is successful (or generation task is already running). Responds with BadRequest...
CWE-352
0
def change_due_date(request, course_id): """ Grants a due date extension to a student for a particular unit. """ course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(course_id)) student = require_student_from_identifier(request.GET.get('student')) unit = find_unit(course, req...
CWE-352
0
def test_modify_access_allow(self): url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'unique_student_identifier': self.other_user.email, 'rolename': 'staff', 'action': 'allow', })...
CWE-352
0
def test_list_background_email_tasks(self, act): """Test list of background email tasks.""" act.return_value = self.tasks url = reverse('list_background_email_tasks', kwargs={'course_id': self.course.id.to_deprecated_string()}) mock_factory = MockCompletionInfo() with patch('...
CWE-352
0
def test_get_problem_responses_successful(self): """ Test whether get_problem_responses returns an appropriate status message if CSV generation was started successfully. """ url = reverse( 'get_problem_responses', kwargs={'course_id': unicode(self.cour...
CWE-352
0
def test_modify_access_bad_role(self): """ Test with an invalid action parameter. """ url = reverse('modify_access', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'unique_student_identifier': self.other_staff.email, 'ro...
CWE-352
0
def call_add_users_to_cohorts(self, csv_data, suffix='.csv', method='POST'): """ Call `add_users_to_cohorts` with a file generated from `csv_data`. """ # this temporary file will be removed in `self.tearDown()` __, file_name = tempfile.mkstemp(suffix=suffix, dir=self.tempdir)...
CWE-352
0
def show_student_extensions(request, course_id): """ Shows all of the due date extensions granted to a particular student in a particular course. """ student = require_student_from_identifier(request.GET.get('student')) course = get_course_by_id(SlashSeparatedCourseKey.from_deprecated_string(cou...
CWE-352
0
def test_create_registration_code_without_invoice_and_order(self): """ test generate detailed enrollment report, used a registration codes which has been created via invoice or bulk purchase scenario. """ course_registration_code = CourseRegistrationCode.objects.creat...
CWE-352
0
def rescore_entrance_exam(request, course_id): """ Starts a background process a students attempts counter for entrance exam. Optionally deletes student state for a problem. Limited to instructor access. Takes either of the following query parameters - unique_student_identifier is an email or u...
CWE-352
0
def test_unicode_encode_error(self, mocker): url = QUrl('file:///tmp/foo') req = QNetworkRequest(url) err = UnicodeEncodeError('ascii', '', 0, 2, 'foo') mocker.patch('os.path.isdir', side_effect=err) reply = filescheme.handler(req) assert reply is None
CWE-352
0
def _access_endpoint(self, endpoint, args, status_code, msg): """ Asserts that accessing the given `endpoint` gets a response of `status_code`. endpoint: string, endpoint for instructor dash API args: dict, kwargs for `reverse` call status_code: expected HTTP status code res...
CWE-352
0
def test_list_course_role_members_bad_rolename(self): """ Test with an invalid rolename parameter. """ url = reverse('list_course_role_members', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'rolename': 'robot-not-a-rolename', ...
CWE-352
0
def test_rescore_problem_single(self, act): """ Test rescoring of a single student. """ url = reverse('rescore_problem', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, 'unique_st...
CWE-352
0
def test_coupon_redeem_count_in_ecommerce_section(self): """ Test that checks the redeem count in the instructor_dashboard coupon section """ # add the coupon code for the course coupon = Coupon( code='test_code', description='test_description', course_id=self.cou...
CWE-352
0
def require_query_params(*args, **kwargs): """ Checks for required paremters or renders a 400 error. (decorator with arguments) `args` is a *list of required GET parameter names. `kwargs` is a **dict of required GET parameter names to string explanations of the parameter """ require...
CWE-352
0
def test_rescore_entrance_exam_all_student(self): """ Test rescoring for all students. """ url = reverse('rescore_entrance_exam', kwargs={'course_id': unicode(self.course.id)}) response = self.client.get(url, { 'all_students': True, }) self.assertEqual(response.st...
CWE-352
0
def test_reset_student_attempts_all(self, act): """ Test reset all student attempts. """ url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, 'a...
CWE-352
0
def test_get_students_features(self): """ Test that some minimum of information is formatted correctly in the response to get_students_features. """ for student in self.students: student.profile.city = "Mos Eisley {}".format(student.id) student.profile...
CWE-352
0
def handler(request): """Handler for a file:// URL. Args: request: QNetworkRequest to answer to. Return: A QNetworkReply for directories, None for files. """ path = request.url().toLocalFile() try: if os.path.isdir(path): data = dirbrowser_html(path) ...
CWE-352
0
def __init__(self): field_infos = [ FieldInfo.factory(key) for key in list(request.form.keys()) + list(request.files.keys()) ] # important to sort them so they will be in expected order on command line self.field_infos = list(sorted(field_infos))
CWE-352
0
def test_get_problem_responses_already_running(self): """ Test whether get_problem_responses returns an appropriate status message if CSV generation is already in progress. """ url = reverse( 'get_problem_responses', kwargs={'course_id': unicode(self.c...
CWE-352
0
def test_reset_student_attempts_nonsense(self): """ Test failure with both unique_student_identifier and all_students. """ url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': se...
CWE-352
0
def test_reset_student_attempts_missingmodule(self): """ Test reset for non-existant problem. """ url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': 'robot-not-a-real-module', ...
CWE-352
0
def test_get_student_exam_results(self): """ Test whether get_proctored_exam_results returns an appropriate status message when users request a CSV file. """ url = reverse( 'get_proctored_exam_results', kwargs={'course_id': unicode(self.course.id)} ...
CWE-352
0
def test_get_problem_responses_invalid_location(self): """ Test whether get_problem_responses returns an appropriate status message when users submit an invalid problem location. """ url = reverse( 'get_problem_responses', kwargs={'course_id': unicode(...
CWE-352
0
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("application/json"); final PrintWriter out = resp.getWriter(); HttpSession session = req.getSession(false); if (session != null) { Subject...
CWE-352
0
public void initWithCustomLogHandler() throws Exception { servlet = new AgentServlet(); config = createMock(ServletConfig.class); context = createMock(ServletContext.class); HttpTestUtil.prepareServletConfigMock(config, new String[]{ConfigKey.LOGHANDLER_CLASS.getKeyValue(), CustomLo...
CWE-352
0
public void accessDenied() { expect(backend.isRemoteAccessAllowed("localhost","127.0.0.1")).andReturn(false); replay(backend); handler.checkClientIPAccess("localhost","127.0.0.1"); }
CWE-352
0
private ModelAndView renameGroup(HttpServletRequest request, HttpServletResponse response) throws Exception { String oldName = request.getParameter("groupName"); String newName = request.getParameter("newName"); if (StringUtils.hasText(oldName) && StringUtils.hasText(newNam...
CWE-352
0
public void preflightCheck() { String origin = "http://bla.com"; String headers ="X-Data: Test"; expect(backend.isCorsAccessAllowed(origin)).andReturn(true); replay(backend); Map<String,String> ret = handler.handleCorsPreflightRequest(origin, headers); assertEquals(...
CWE-352
0
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(false); if (session == null) { AccessControlContext acc = AccessController.getContext(); Subject subject = Subject.getS...
CWE-352
0
public void withRestrictor() throws InvalidSyntaxException, MalformedObjectNameException { setupRestrictor(new InnerRestrictor(true,false,true,false,true,false,true)); assertTrue(restrictor.isHttpMethodAllowed(HttpMethod.GET)); assertFalse(restrictor.isTypeAllowed(RequestType.EXEC)); ...
CWE-352
0
public boolean isCorsAccessAllowed(String pOrigin) { return restrictor.isCorsAccessAllowed(pOrigin); }
CWE-352
0
public boolean isCorsAccessAllowed(String pOrigin) { return isAllowed; }
CWE-352
0
public void preflightCheckNegative() { String origin = "http://bla.com"; String headers ="X-Data: Test"; expect(backend.isCorsAccessAllowed(origin)).andReturn(false); replay(backend); Map<String,String> ret = handler.handleCorsPreflightRequest(origin, headers); asse...
CWE-352
0
public void initWithAgentDiscoveryAndUrlCreationAfterGet() throws ServletException, IOException { checkMulticastAvailable(); prepareStandardInitialisation(ConfigKey.DISCOVERY_ENABLED.getKeyValue(), "true"); try { StringWriter sw = initRequestResponseMocks(); expect(re...
CWE-352
0
public RechnungCostEditTablePanel(final String id) { super(id); feedbackPanel = new FeedbackPanel("feedback"); ajaxComponents.register(feedbackPanel); add(feedbackPanel); this.form = new Form<AbstractRechnungsPositionDO>("form"); add(form); rows = new RepeatingView("rows"); form.add(...
CWE-352
0
public void corsEmpty() { InputStream is = getClass().getResourceAsStream("/allow-origin3.xml"); PolicyRestrictor restrictor = new PolicyRestrictor(is); assertTrue(restrictor.isCorsAccessAllowed("http://bla.com")); assertTrue(restrictor.isCorsAccessAllowed("http://www.jolokia.org"))...
CWE-352
0
public void setupRoutes() { path(controllerBasePath(), () -> { before("", mimeType, this::setContentType); // change the line below to enable appropriate security before("", mimeType, this.apiAuthenticationHelper::checkAdminUserAnd403); get("", mimeType, th...
CWE-352
0
public void debug() throws IOException, ServletException { servlet = new AgentServlet(); initConfigMocks(new String[]{ConfigKey.DEBUG.getKeyValue(), "true"},null,"No access restrictor found",null); context.log(find("URI:")); context.log(find("Path-Info:")); context.log(find("...
CWE-352
0
public void corsWildCard() { InputStream is = getClass().getResourceAsStream("/allow-origin2.xml"); PolicyRestrictor restrictor = new PolicyRestrictor(is); assertTrue(restrictor.isCorsAccessAllowed("http://bla.com")); assertTrue(restrictor.isCorsAccessAllowed("http://www.jolokia.org...
CWE-352
0
public boolean isCorsAccessAllowed(String pOrigin) { return corsChecker.check(pOrigin); }
CWE-352
0
private Runnable getStandardRequestSetup() { return new Runnable() { public void run() { expect(request.getHeader("Origin")).andReturn(null); expect(request.getRemoteHost()).andReturn("localhost"); expect(request.getRemoteAddr()).andReturn("127.0.0...
CWE-352
0
private void returnPrincipals(Subject subject, PrintWriter out) { Map<String, Object> answer = new HashMap<String, Object>(); List<Object> principals = new ArrayList<Object>(); for (Principal principal : subject.getPrincipals()) { Map<String, String> data = new HashMap<String,...
CWE-352
0
public boolean check(String pArg) { if (patterns == null || patterns.size() == 0) { return true; } for (Pattern pattern : patterns) { if (pattern.matcher(pArg).matches()) { return true; } } return false; }
CWE-352
0
public CorsChecker(Document pDoc) { NodeList corsNodes = pDoc.getElementsByTagName("cors"); if (corsNodes.getLength() > 0) { patterns = new ArrayList<Pattern>(); for (int i = 0; i < corsNodes.getLength(); i++) { Node corsNode = corsNodes.item(i); ...
CWE-352
0
public void checkClientIPAccess(String pHost, String pAddress) { if (!backendManager.isRemoteAccessAllowed(pHost,pAddress)) { throw new SecurityException("No access from client " + pAddress + " allowed"); } }
CWE-352
0
public void simpleGetWithUnsupportedGetParameterMapCall() throws ServletException, IOException { prepareStandardInitialisation(); StringWriter sw = initRequestResponseMocks( new Runnable() { public void run() { expect(request.getHeader("Ori...
CWE-352
0
private void checkCorsGetOrigin(final String in, final String out) throws ServletException, IOException { prepareStandardInitialisation(); StringWriter sw = initRequestResponseMocks( new Runnable() { public void run() { expect(request.getH...
CWE-352
0
public void cors() { InputStream is = getClass().getResourceAsStream("/allow-origin1.xml"); PolicyRestrictor restrictor = new PolicyRestrictor(is); assertTrue(restrictor.isCorsAccessAllowed("http://bla.com")); assertFalse(restrictor.isCorsAccessAllowed("http://www.jolokia.org")); ...
CWE-352
0
public CsrfTokenHandler(final Form< ? > form) { form.add(csrfTokenField = new HiddenField<String>("csrfToken", Model.of(getCsrfSessionToken()))); }
CWE-352
0
private void initConfigMocks(String[] pInitParams, String[] pContextParams,String pLogRegexp, Class<? extends Exception> pExceptionClass) { config = createMock(ServletConfig.class); context = createMock(ServletContext.class); String[] params = pInitParams != null ? Arrays.copyOf(pInitParam...
CWE-352
0
public Map<String, String> handleCorsPreflightRequest(String pOrigin, String pRequestHeaders) { Map<String,String> ret = new HashMap<String, String>(); if (pOrigin != null && backendManager.isCorsAccessAllowed(pOrigin)) { // CORS is allowed, we set exactly the origin in the header, so th...
CWE-352
0
private ModelAndView renameGroup(HttpServletRequest request, HttpServletResponse response) throws Exception { String oldName = request.getParameter("groupName"); String newName = request.getParameter("newName"); if (StringUtils.hasText(oldName) && StringUtils.hasText(newNam...
CWE-352
0
public void corsAccessCheck() { BackendManager backendManager = new BackendManager(config,log); assertTrue(backendManager.isCorsAccessAllowed("http://bla.com")); backendManager.destroy(); }
CWE-352
0
private void handle(ServletRequestHandler pReqHandler,HttpServletRequest pReq, HttpServletResponse pResp) throws IOException { JSONAware json = null; try { // Check access policy requestHandler.checkClientIPAccess(pReq.getRemoteHost(),pReq.getRemoteAddr()); // Re...
CWE-352
0
public String extractCorsOrigin(String pOrigin) { if (pOrigin != null) { // Prevent HTTP response splitting attacks String origin = pOrigin.replaceAll("[\\n\\r]*",""); if (backendManager.isCorsAccessAllowed(origin)) { return "null".equals(origin) ? "*" : ...
CWE-352
0
def add_acl_usergroup(session, acl_role_id, user_group, name) if (user_group == "user") or (user_group == "group") stdout, stderr, retval = run_cmd( session, PCS, "acl", user_group, "create", name.to_s, acl_role_id.to_s ) if retval == 0 return "" end if not /^error: (user|group) #{name...
CWE-384
1
def remote_add_node(params, request, session, all=false) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end auto_start = false if params[:auto_start] and params[:auto_start] == "1" auto_start = true end if params[:new_nodename] != nil node = params[...
CWE-384
1
def get_configs_cluster(nodes, cluster_name) data = { 'cluster_name' => cluster_name, } $logger.debug 'Fetching configs from the cluster' threads = [] node_configs = {} nodes.each { |node| threads << Thread.new { code, out = send_request_with_token( ...
CWE-384
1
def auth(params, request, session) token = PCSAuth.validUser(params['username'],params['password'], true) # If we authorized to this machine, attempt to authorize everywhere node_list = [] if token and params["bidirectional"] params.each { |k,v| if k.start_with?("node-") node_list.push(v) ...
CWE-384
1
def add_node_attr_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end retval = add_node_attr( session, params["node"], params["key"], params["value"] ) # retval = 2 if removing attr which doesn't exist if retval == 0 or r...
CWE-384
1
def add_fence_level(session, level, devices, node, remove = false) if not remove stdout, stderr, retval = run_cmd( session, PCS, "stonith", "level", "add", level, node, devices ) return retval,stdout, stderr else stdout, stderr, retval = run_cmd( session, PCS, "stonith", "level", "remove...
CWE-384
1
def authorize_params super.tap do |params| %w[display state scope].each do |v| if request.params[v] params[v.to_sym] = request.params[v] # to support omniauth-oauth2's auto csrf protection session['omniauth.state'] = params[:state] if v == '...
CWE-352
0
def resource_cleanup(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end stdout, stderr, retval = run_cmd( session, PCS, "resource", "cleanup", params[:resource] ) if retval == 0 return JSON.generate({"success" => "true"}) e...
CWE-384
1
def save_tokens(params, request, session) # pcsd runs as root thus always returns hacluster's tokens if not allowed_for_local_cluster(session, Permissions::FULL) return 403, "Permission denied" end new_tokens = {} params.each{|nodes| if nodes[0].start_with?"node:" and nodes[0].length > 5 node ...
CWE-384
1
def add_acl_permission(session, acl_role_id, perm_type, xpath_id, query_id) stdout, stderror, retval = run_cmd( session, PCS, "acl", "permission", "add", acl_role_id.to_s, perm_type.to_s, xpath_id.to_s, query_id.to_s ) if retval != 0 if stderror.empty? return "Error adding permission" else ...
CWE-384
1
def enable_cluster(session) stdout, stderror, retval = run_cmd(session, PCS, "cluster", "enable") return false if retval != 0 return true end
CWE-384
1
def cluster_start(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'cluster_start', true ) else if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end $logger.info "Starting Daemons...
CWE-384
1
def resource_ungroup(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end unless params[:group_id] return [400, 'group_id has to be specified.'] end _, stderr, retval = run_cmd( session, PCS, 'resource', 'ungroup', params[:...
CWE-384
1
def remove_constraint_rule_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end if params[:rule_id] retval = remove_constraint_rule(session, params[:rule_id]) if retval == 0 return "Constraint rule #{params[:rule_id]} ...
CWE-384
1
def add_constraint_set_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end case params["c_type"] when "ord" retval, error = add_order_set_constraint( session, params["resources"].values, params["force"], !params['...
CWE-384
1
def send_cluster_request_with_token(session, cluster_name, request, post=false, data={}, remote=true, raw_data=nil) $logger.info("SCRWT: " + request) nodes = get_cluster_nodes(cluster_name) return send_nodes_request_with_token( session, nodes, request, post, data, remote, raw_data ) end
CWE-384
1
def cluster_status_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end cluster_name = $cluster_name # If node is not in a cluster, return empty data if not cluster_name or cluster_name.empty? overview = { :cluster_nam...
CWE-384
1
def get_avail_resource_agents(params, request, session) if not allowed_for_local_cluster(session, Permissions::READ) return 403, 'Permission denied' end agents = getResourceAgents(session) return JSON.generate(agents) end
CWE-384
1
def get_permissions_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::GRANT) return 403, 'Permission denied' end pcs_config = PCSConfig.new(Cfgsync::PcsdSettings.from_file('{}').text()) data = { 'user_types' => Permissions::get_user_types(), 'permission_types' ...
CWE-384
1
def add_location_constraint_rule( session, resource, rule, score, force=false, autocorrect=true ) cmd = [PCS, "constraint", "location", resource, "rule"] if score != '' if is_score(score.upcase) cmd << "score=#{score.upcase}" else cmd << "score-attribute=#{score}" end end cmd.concat(ru...
CWE-384
1
def getAllSettings(session, cib_dom=nil) unless cib_dom cib_dom = get_cib_dom(session) end ret = {} if cib_dom cib_dom.elements.each('/cib/configuration/crm_config//nvpair') { |e| ret[e.attributes['name']] = e.attributes['value'] } end return ret end
CWE-384
1
def add_acl_role(session, name, description) cmd = [PCS, "acl", "role", "create", name.to_s] if description.to_s != "" cmd << "description=#{description.to_s}" end stdout, stderror, retval = run_cmd(session, *cmd) if retval != 0 return stderror.join("\n").strip end return "" end
CWE-384
1
def add_constraint_rule_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::WRITE) return 403, 'Permission denied' end if params["c_type"] == "loc" retval, error = add_location_constraint_rule( session, params["res_id"], params["rule"], params["score"], para...
CWE-384
1
def self.loginByPassword(session, username, password) if validUser(username, password) session[:username] = username success, groups = getUsersGroups(username) session[:usergroups] = success ? groups : [] return true end return false end
CWE-384
1
def get_configs(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end if not $cluster_name or $cluster_name.empty? return JSON.generate({'status' => 'not_in_cluster'}) end if params[:cluster_name] != $cluster_name return JSON.gen...
CWE-384
1
def config_backup(params, request, session) if params[:name] code, response = send_request_with_token( session, params[:name], 'config_backup', true ) else if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end $logger.info "Backup node confi...
CWE-384
1
def get_local_node_id() if ISRHEL6 out, errout, retval = run_cmd( PCSAuth.getSuperuserSession, COROSYNC_CMAPCTL, "cluster.cman" ) if retval != 0 return "" end match = /cluster\.nodename=(.*)/.match(out.join("\n")) if not match return "" end local_node_name = match[1] ...
CWE-384
1
def send_nodes_request_with_token(session, nodes, request, post=false, data={}, remote=true, raw_data=nil) out = "" code = 0 $logger.info("SNRWT: " + request) # If we're removing nodes, we don't send this to one of the nodes we're # removing, unless we're removing all nodes if request == "/remove_nodes" ...
CWE-384
1
def remove_constraint_rule(session, rule_id) stdout, stderror, retval = run_cmd( session, PCS, "constraint", "rule", "remove", rule_id ) $logger.info stdout return retval end
CWE-384
1
def add_location_constraint( session, resource, node, score, force=false, autocorrect=true ) if node == "" return "Bad node" end if score == "" nodescore = node else nodescore = node + "=" + score end cmd = [PCS, "constraint", "location", resource, "prefers", nodescore] cmd << '--force' if...
CWE-384
1
def allowed_for_superuser(session) $logger.debug( "permission check superuser username=#{session[:username]} groups=#{session[:groups]}" ) if SUPERUSER != session[:username] $logger.debug('permission denied') return false end $logger.debug('permission granted for superuser') return true end
CWE-384
1
def add_acl_role_remote(params, request, session) if not allowed_for_local_cluster(session, Permissions::GRANT) return 403, 'Permission denied' end retval = add_acl_role(session, params["name"], params["description"]) if retval == "" return [200, "Successfully added ACL role"] else return [ ...
CWE-384
1
def setup_cluster(params, request, session) if not allowed_for_superuser(session) return 403, 'Permission denied' end $logger.info("Setting up cluster: " + params.inspect) nodes_rrp = params[:nodes].split(';') options = [] myoptions = JSON.parse(params[:options]) transport_udp = false options_udp = ...
CWE-384
1
def remote_node_available(params, request, session) if (not ISRHEL6 and File.exist?(Cfgsync::CorosyncConf.file_path)) or (ISRHEL6 and File.exist?(Cfgsync::ClusterConf.file_path)) or File.exist?("/var/lib/pacemaker/cib/cib.xml") return JSON.generate({:node_available => false}) end return JSON.generate({:node_a...
CWE-384
1
def remote_remove_node(params, request, session) if not allowed_for_local_cluster(session, Permissions::FULL) return 403, 'Permission denied' end if params[:remove_nodename] != nil retval, output = remove_node(session, params[:remove_nodename]) else return 400, "No nodename specified" end if re...
CWE-384
1
def run_auth_requests(session, nodes_to_send, nodes_to_auth, username, password, force=false, local=true) data = {} nodes_to_auth.each_with_index { |node, index| data["node-#{index}"] = node } data['username'] = username data['password'] = password data['bidirectional'] = 1 if not local data['force'] ...
CWE-384
1