Get tagging to work on AWS CLI

I am trying to tag commit hash and app version onto the ECS service to make it easier for developers to identify the service with the code.

But I get this error

+ aws ecs tag-resource --resource-arn arn:aws:ecs:ap-southeast-1:12344556677:service/master-web-dev-WebECSServices --tags key=COMMITHASH,value=85491def key=VERSION,value=0.2.4
An error occurred (InvalidParameterException) when calling the TagResource operation: Long arn format must be used for tagging operations

Is there any problem with the ARN? why do I always get this issue?

Go to Source
Author: Moses Liao GZ

What is the correct way to call a PHP Function with multiple parameters from the AJAX Handler?

Q: What is the correct way to call a PHP Function with multiple parameters from the AJAX Handler?

Q: Am I calling the php function correctly?


Page Element
The user clicks a button.

Action:
The click should connect to an external server using the following params:

  1. User Name 2. IP Address 3. Port 4. Public Key 5. Service

Purpose:
Send an vote string (from host A) to an external Gaming server (host B).
I do not need to update any wordpress content.

WordPress Version: 5.4.1
I put my custom php code into “/wp-contents/plugins/my-plugin/votifier.php”

I made sure the custom plugin is activated.

I have WordPress in Debug mode. i.e. Debug mode is true.

The Button

<div id="frm_field_61_container">
<button type="button">Try it</button>
</div>

WordPress JQuery with AJAX

jQuery(document).ready( function($) {
 $("#frm_field_61_container").click(function(){

      jQuery.ajax({

         type : "post",

         dataType : "json",

         url : myAjax.ajaxurl,

         data : {    action: "my_vote_count"
                    ,username: $('input[name="item_meta[59]"]').val()
                    ,key: $.trim($("#field_yjr62").val())
                    ,ip: $('input[name="item_meta[40]"]').val()
                    ,port: $('input[name="item_meta[42]"]').val()
                    ,service: "Votifier"
                },

        success:    function(data,status,xhr){
                    alert("Data: " + data);
                    alert("Status: " + status);
                    alert("xhr: " + xhr);
                }
      });   
   });
});

My Custom PHP Script

<?php


function mainVotifier($username, $public_key, $server_ip, $port, $service_name) {

define( 'VOTE_FORMAT', 'VOTEn%sn%sn%sn%dn' );
define( 'PUBLIC_KEY_FORMAT', '-----BEGIN PUBLIC KEY-----n%sn-----END PUBLIC KEY-----' );

$key    = wordwrap($public_key, 65, "n", true);
$key    = sprintf(PUBLIC_KEY_FORMAT, $key);


  if (php_sapi_name() !== 'cli') {
            //Detect proxy and use correct IP.
            $address = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
        } else {
            //Script is run via CLI, use server name.
            $address = $_SERVER['SERVER_NAME'];
        }

    $data = sprintf(VOTE_FORMAT, $service_name, $username, $address, time());
    openssl_public_encrypt($data, $crypted, $key);
    $socket = @fsockopen($server_ip, $port);

    if ($socket) {
        if (fwrite($socket, $crypted)) {
            fclose($socket);
            return true;
        }
    }

}

?>

/* ===== WP_ENQUEUE SCRIPTS ==== */

/* ===== JQuery Ajax Script to call votifier.php ==== */
add_action( 'wp_enqueue_scripts', 'my_script_enqueuer' );
function my_script_enqueuer() {

   wp_enqueue_script( 'my_voter_script',  plugins_url('sendvote.js', __FILE__), array( 'jquery'),   '1.0', true);

   wp_localize_script( 'my_voter_script', 'myAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));

}

/* ===== My AJAX Handler ==== */

/* add_action( 'wp_ajax_nopriv_my_vote_count', 'my_ajax_handler' ); */ 
add_action( 'wp_ajax_my_vote_count', 'my_ajax_handler');
function my_ajax_handler() {

/*  check_ajax_referer('votifier_response_key'); */

    $username       = $_POST["username"];
    $public_key     = $_POST['key'];
    $server_ip      = $_POST["ip"];
    $port           = $_POST["port"];   
    $service_name   = $_POST["service"];

   echo "mainVotifier("" . $username . "", "" . $public_key . "", "" . $server_ip . "", "" . $port . "", "" . $service_name . "");";


    wp_die(); // All ajax handlers die when finished

}

Console Results

The console results are good, but the other server is not responding.
I tested the PHP code locally from my personal computer and Server B is responding.


Request URL:https://bestminecraftserverlist.com/wp-admin/admin-ajax.php
Request Method:POST
Remote Address:192.169.170.42:443
Status Code:
200
Version:HTTP/2

Go to Source
Author: ScottUSA

How to query/join tables where foreign key constraint is set in schema

I’m relatively new to sqlite and databases in general.
I’ve successfully setup a schema of 4 tables, each having a foreign key pointing to its parent table. The schema also has the foreign key constraint set on the child keys.

Performing a query where every table is joined with the SELECT * FROM…JOIN…ON ……… works without issue, but it is laborious manually connecting the keys.

My question is: Is it possible to perform a query/join of the tables without the ON statement which links each parent/child key relationship? Since this was already established in the schema definition, this seems to be redundant. I’m trying to simplify the sql command and make use of the parent/child relationship already defined. When I perform said query but omit the ON statements, the results are not what I expected. Any guidance is appreciated.

Go to Source
Author: Bill Fujimoto

Architecture of Online Chess (2-player web-based board game)?

I’d like to try to create an application where 2 players can play chess online. The (possibly) novel feature would be that the process for joining a game would be similar to how Typeracer works. The first player creates a lobby then shares a link. The friend can then click the link to join the session immediately.

However, I’m a beginner when it comes to how information is shared over the internet. I’ve only created a few REST APIs and games in Java/Python so a lot of this would be new to me.

The first question I have is how/where would I actually implement the logic for this game? Would everything be done client-side (I’d probably use React so I’d then have a js library to hold all game rules) Or is everything done on the server?

Also, how would I keep the player’s game clients in sync? I’ve heard about websockets but any elaboration would be helpful.

Lastly, how could I go about implementing the feature where users can share their game link to get the other player to join?

For context, I have quite a bit of experience with React for UI, I’ve used NodeJS on the server, and I’m currently learning about how to create web APIs with ASP.NET web API (C#). I figure that I’ll be able to create the board UI in React and handle any animations with CSS. If that’s not a good idea let me know!

Overall I’m not really sure how I’ll tie this all together so a big picture view might help; and I’ve love to hear about any frameworks or tools that might make this job easier; thanks for the help in advance!

Go to Source
Author: Brad Stevanus

i am getting an error of ‘turtle’ has no attribute ‘Turtle’

The mistakes done in the turtle library

1 : saving the file as “turtle.py”

2 : using the lower case for library as turtle.turtle()….the correct form is turtle.Turtle()

3 : if you have done the first mistake of saving the file as “turtle.py” don’t rename the file in the same folder …try a new place to save the file.

Go to Source
Author: Suchit Borge

How to add PPA source for this gcc-10 package?

I know that to add a PPA, we use:

add-apt-repository ppa:user/ppa-name

But for this package : gcc-10, what is user and ppa-name?

I have tried:

add-apt-repository ppa:ubuntu/gcc-10
add-apt-repository ppa:gcc-10
add-apt-repository ppa:focal/gcc-10

They all fails with:

user or team does not exist.

Go to Source
Author: kilasuelika

Why do I have a directory called .ecryptfs full of files when I do not have my file system encrypted?

(Revisiting the eCryptfs headers errors post from 2015)

In my /var/log/syslog file, I was seeing the error

Valid eCryptfs headers not found in file header region or xattr region, inode 7080159

I used @GiovanniToraldo’s suggestion

find / -inum 7080159

and found the errant file in the /home/.ecryptfs/<user>/.Private/... directory. The file size was 8192 and the file date was July 10, 2019 (last year.) So I deleted the file.

Why do I have a directory for .ecryptfs when I do not have my file system encrypted? Can I just delete the entire .ecryptfs directory?

Note: I am running Ubuntu 14.04 LTS on a desktop computer with a RS880 [Radeon HD 4250] video card that is no longer supported by the Linux kernel beyond 14.04 LTS, so I cannot upgrade Ubuntu without buying a new computer.

Go to Source
Author: Stephen Daddona

Can you edit /etc/passwd on a firmware image?

I’m trying to gain root access on a cheap DVR that I bought for a CCTV system. The manufacturer has a firmware update image available for download that I was able to inspect using a tool called binwalk and I extracted the rootfs. It looks like a flavor of embedded Linux with Busybox.

I took a look at the /etc/passwd file and it has one line for root with a password hash and a login shell defined. There’s no /etc/shadow file but there is a /etc/passwd- which I haven’t seen before.

I also found an init script that would normally be launching telnetd but it’s commented out.

Can I just generate a new password hash to substitute in /etc/passwd, uncomment the telnetd line and then log in as root with the new password through telnet over the network?

(Of course this is ignoring the possible problems I could run into with flashing the new firmware onto the device and bricking it)

Go to Source
Author: jvergeldedios

Try to run Python programm from command line. ImportError: No module named mysql.connector

I’m new in programming. So I have a question about this error.
I’m trying to run programm from command line in PyCharm, and get this Error.

root@kali:~# python /root/PycharmProjects/lesson/ProL3/ner.py
Traceback (most recent call last):
File “/root/PycharmProjects/lesson/ProL3/ner.py”, line 2, in
import mysql.connector as sql
ImportError: No module named mysql.connector

Prog:

import mysql.connector as sql
from mysql.connector import Error
import argparse


connection = sql.connect(
    host="localhost",
    password="mroot",
    user="myro"
)
mycursor = connection.cursor()

parser = argparse.ArgumentParser(description='Database management', usage='Script option:')
parser.add_argument('-d', '--data', help="Create Databases")
args = parser.parse_args()

class Data:
    def __init__(self, database=''):
        self.database = database
        self.create_database()

    def create_database(self):
        try:
            mycursor.execute(self.database)
            print("The database was created!")
        except Error as e:
            print(e)


What should I do?

Go to Source
Author: Boboc

How can I ensure the client and server both have access to all API calls in use?

On multiple occasions, we’ve deployed frontend code to production only to find out the backend (REST or GraphQL) hasn’t shipped their side yet. Worse yet, we expectedly find out a param name changed which may throw an error. Another example: the backend removes an API thinking that clients no longer use the removed API and the frontend crashes. If any layer of communication between frontend and backend breaks down, then we may end up with catastrophic errors.

I think the “best solution” is to use a tool like Cypress or Codecept to create a suite of integration tests which checks every API call the frontend may use. Sadly, that’s a heavyweight solution that requires significant upfront investment in developer time.

Anyway, I’m looking for simple solution to this problem. Maybe something that checks affected APIs when the frontend opens a PR and/or something that checks the frontend repo when the backend deploys to production.

Any ideas or experience solving this problem?

Go to Source
Author: Brandon

Synchronize time among several concurrent users

I’m using Google Sheets to come up with a quick Jeopardy-style game with an improvised buzzer. All players type in the timestamp shortcut (Ctrl+Shift+0) into a cell and the lowest value is presumed to buzz in first, but we’ve realized that some people are a few seconds, even minutes, ahead (or behind). We’ve diagnosed that it’s related to each person’s time set in each’s OS.

Is there a way to sync times through the Sheets app? Or at the very least determine who input first?

I’ve tried to remedy with a series of nested array formula with if and count statements, but to no avail. Any help would be appreciated. Otherwise I’m going to set my OS’s time to 1899 and smoke everyone.

Go to Source
Author: Rudy A

what is an example of out of bounds read in order to leak sensitive information?

I Am trying to understand a little bit better behind the scenes on bypassing aslr by reading the bytes in the memory of a process, but how can I make an example of an info leak in WIN32? my code does the leaks of bytes , but how can I check the image base based on those bytes?

#include <stdio.h>
#include <string.h>

int main(int argc, char **argv) {
    char a[16];

    strncpy(a, "0123456789abcdef", sizeof(a));

    //... lots of code passes, functions are called...
    //... we finally come back to array a ...

    printf("%sn", a);
}

Go to Source
Author: pepe

Jinja syntax error: missing endif, in spite of providing it

I am using Salt 2019.2.0 version and below is my state file where I am using if condition to check the values and run states if it’s a match. Even if I have provided endif, it says Jinja looking for missing endif tag. Any help please?

CODE:

{% if salt['pillar.get']('spade:Corename') == 'FI' and salt['pillar.get']('spade:NodeType') == 'master' %}dataimport-script:file.managed:- name: /opt/bin/DataImport.py- source: salt://files/DataImport.py

dataimport-crontab:file.managed:- name: /etc/cron.d/solr-dataimport- contents: |# # set up data import for FI every 2 minutes*/2 * * * * root /usr/bin/python /opt/bin/DataImport.py

{% elif salt['pillar.get']('spade:NodeType') in ['slave','ds'] and salt['pillar.get']('spade:Corename') == 'FI' %}update-fi-solrconfig:file.replace:- name: {{ salt['pillar.get']('solr:home_dir') }}/data/{{ salt['pillar.get']('spade:Corename') }}/conf/solrconfig.xml- pattern: '"autoDeletePeriodSeconds">30'- repl: '"autoDeletePeriodSeconds">-1'{% endif %}

ERROR:


local:

Data failed to compile:

----------

Rendering SLS 'base:solr.install-solr' failed: Jinja syntax error: Unexpected end of template. Jinja was looking for the following tags: 'endif'. The innermost block that needs to be closed is 'if'.; line 205

---

[...]

update-fi-solrconfig:

file.replace:

- name: {{ salt['pillar.get']('solr:home_dir') }}/data/{{ salt['pillar.get']('spade:Corename') }}/conf/solrconfig.xml

- pattern: '"autoDeletePeriodSeconds">30'

- repl: '"autoDeletePeriodSeconds">-1'

{% endif %} <======================

Go to Source
Author: user22405