I have such a code in json file and need to find password from special array using regular expression. For example, i want to find the password from sftpConfig not pbx
"pbx": {
"dbConfig": {
"username": "postgres",
"password": "postgres",
"database": "autocaller",
"host": "postgres",
"dialect": "postgres",
"operatorsAliases": false,
"dialectOptions": {
"connectTimeout": 60000,
"options": {
"requestTimeout": 3000
}
},
"pool": {
"max": 10,
"min": 0,
"idle": 10000
}
}
},
"strapi": {
"credentials": {
"identifier": "admin",
"password": "admin"
}
},
"sftpConfig":{
"host": "1.1.1.1",
"port": "22",
"username": "admin",
"password": "admin1"
}
Related
I am trying to make my json file that looks like this
{
"database_details": {
"age": "false",
"help": "xxxx",
"host": "",
"servername": "fra02",
"db_name": "config_tools",
"pass": "xxxx",
"user": "default",
},
{
"age": "false",
"help": "xxxx",
"host": "",
"servername": "fra03",
"db_name": "config_tools",
"pass": "xxxx",
"user": "default",
}
}
to look like
{
"database_details": {
"fra02":{
"age": "false",
"help": "xxxx",
"host": "",
"servername": "fra02",
"db_name": "config_tools",
"pass": "xxxx",
"user": "default",
},
"fra03": {
"age": "false",
"help": "xxxx",
"host": "",
"servername": "fra02",
"db_name": "config_tools",
"pass": "xxxx",
"user": "default",
}
}
}
I have tried jq but not sure if that is the right approach?
I have thought about using awk or sed but not sure that is the cleanest route?
Assuming valid JSON like
{
"database_details": [
{
"age": "false",
"help": "xxxx",
"host": "",
"servername": "fra02",
"db_name": "config_tools",
"pass": "xxxx",
"user": "default"
},
{
"age": "false",
"help": "xxxx",
"host": "",
"servername": "fra03",
"db_name": "config_tools",
"pass": "xxxx",
"user": "default"
}
]
}
you can use the filter
.database_details |= (map({key: .servername, value: .}) | from_entries)
The array associated with database_details is turned into an array of key/value pairs, which from_entries turns into a new object that |= assigns back to the key database_details in the original object.
I would like to validate the following json:
{
"endpoints": [
{
"ip_name": "plantuml_ip",
"ip": "172.18.0.2",
"ports": [
{
"name": "plantuml_port",
"port": 8080,
"proto": "HTTPS_TERM"
}
]
}
],
"subdomains": [
{
"name": "plantuml_port",
"value": "plantuml"
}
]
}
If proto contains value HTTPS_TERM, then subdomains with the same name should exists (plantuml_port). Here is an another valid example:
Valid:
{
"endpoints": [{
"ip_name": "plantuml_ip",
"ip": "172.18.0.2",
"ports": [{
"name": "plantuml_port",
"port": 8080,
"proto": "HTTPS_TERM"
}, {
"name": "random_port",
"port": 8181,
"proto": "HTTPS_TERM"
}, {
"name": "no_subdomain",
"port": 999,
"proto": "NO_SUBDOMAIN"
}]
}],
"subdomains": [{
"name": "plantuml_port",
"value": "plantuml"
}, {
"name": "random_port",
"value": "random"
}]
}
It is something like this possible? Thanks in advance!
I'm trying to push JSON from a service in to Firebase, and it's not accepting it.
I cant figure out why. JSONLint validates it as valid.
The error I get is:
error: "Invalid data; couldn't parse JSON object, array, or value."
Here's the JSON payload:
{
"app_id": "e4805b8d5a9f4032b0bb8b6d9c6726b8",
"archived": false,
"attachments": {
"form.xml": {
"content_type": "text/xml",
"length": 4500,
"url": "https://someurl.com/form.xml"
}
},
"build_id": "3c5703e20346462ebcb07a3f36d5fe9b",
"domain": "my-test",
"edited_by_user_id": null,
"edited_on": null,
"form": {
"#type": "data",
"#name": "Beneficiary Registration",
"#uiVersion": "1",
"#version": "1",
"#xmlns": "http://openrosa.org/formdesigner/123456",
"beneficiary_age": {
"beneficiary_age_num": "8",
"beneficiary_exact_age_ind": "N"
},
"beneficiary_gender_cd": "M",
"beneficiary_id": "Hhr-O6I3C5L-J3G1L",
"case": {
"#case_id": "a07972bc-1a34-4c84-90ea-91250639f2a4",
"#date_modified": "2020-03-17T20:57:26.986000Z",
"#user_id": "2275c340c48ac83b6852035b0a15b5d3",
"#xmlns": "http://someurl.org/case/transaction/v2"
},
"case_name": "Hhr-O6I3C5L-J3G1L|joel galager|Katsekera|Katsekera|Mpando|Katsekera|KE",
"existing_beneficiaries": "Jane Doe\n\nJoan Doe",
"existing_beneficiaries_label": "",
"household_information": {
"beneficiary_household_information_display": "",
"beneficiary_location_hierarchy_1": "KE",
"beneficiary_location_hierarchy_1_text": "Kenya",
"beneficiary_location_hierarchy_2": "HF0001",
"beneficiary_location_hierarchy_2_text": "Katsekera",
"beneficiary_location_hierarchy_3": "TA0001",
"beneficiary_location_hierarchy_3_text": "Mpando",
"beneficiary_location_hierarchy_4": "GHV0001",
"beneficiary_location_hierarchy_4_text": "Katsekera",
"beneficiary_location_hierarchy_5": "V0001",
"beneficiary_location_hierarchy_5_text": "Katsekera",
"correct_information": "",
"hh_first_name": "John",
"hh_full_name": "John Doe",
"hh_id_fk": "Hhr-O6I3C5L",
"hh_last_name": "Doe",
"household_information": ""
},
"meta": {
"#xmlns": "http://openrosa.org/jr/xforms",
"appVersion": "Formplayer Version: 2.47",
"app_build_version": 1,
"commcare_version": null,
"deviceID": "Formplayer",
"drift": "0",
"geo_point": null,
"instanceID": "123-321-232",
"timeEnd": "2020-03-17T20:57:26.986000Z",
"timeStart": "2020-03-17T20:57:13.958000Z",
"userID": "2275c340c48ac83b6852035b0a15b5d3",
"username": "some_username"
},
"name_group": {
"beneficiary_first_name": "joel",
"beneficiary_full_name": "joel galager",
"beneficiary_last_name": "galager"
},
"subcase_0": {
"case": {
"#case_id": "2a4bfe27-a5c3-4f3a-8540-5f8ded86db85",
"#date_modified": "2020-03-17T20:57:26.986000Z",
"#user_id": "abc123",
"#xmlns": "http://commcarehq.org/case/transaction/v2",
"create": {
"case_name": "Hhr-O6I3C5L-J3G1L|joel galager|Katsekera|Katsekera|Mpando|Katsekera|KE",
"case_type": "beneficiary_case",
"owner_id": "abc123"
},
"index": {
"parent": {
"#text": "a07972bc-1a34-4c84-90ea-91250639f2a4",
"#case_type": "household_case"
}
},
"update": {
"beneficiary_age_num": "8",
"beneficiary_exact_age_ind": "N",
"beneficiary_first_name": "joel",
"beneficiary_full_name": "joel galager",
"beneficiary_gender_cd": "M",
"beneficiary_id": "Hhr-O6I3C5L-J3G1L",
"beneficiary_last_name": "galager",
"beneficiary_location_hierarchy_1": "KE",
"beneficiary_location_hierarchy_1_text": "Kenya",
"beneficiary_location_hierarchy_2": "HF0001",
"beneficiary_location_hierarchy_2_text": "Katsekera",
"beneficiary_location_hierarchy_3": "TA0001",
"beneficiary_location_hierarchy_3_text": "Mpando",
"beneficiary_location_hierarchy_4": "GHV0001",
"beneficiary_location_hierarchy_4_text": "Katsekera",
"beneficiary_location_hierarchy_5": "V0001",
"beneficiary_location_hierarchy_5_text": "Katsekera",
"hh_id_fk": "Hhr-O6I3C5L"
}
}
}
},
"id": "d547ccea-503c-4c50-b974-38ed564ae78a",
"indexed_on": "2020-03-17T21:01:04.695654",
"initial_processing_complete": true,
"is_phone_submission": true,
"metadata": {
"appVersion": "Formplayer Version: 2.47",
"app_build_version": 1,
"commcare_version": null,
"deviceID": "Formplayer",
"drift": "0",
"geo_point": null,
"instanceID": "01010101",
"location": null,
"timeEnd": "2020-03-17T20:57:26.986000Z",
"timeStart": "2020-03-17T20:57:13.958000Z",
"userID": "2275c340c48ac83b6852035b0a15b5d3",
"username": "myusername"
},
"problem": null,
"received_on": "2020-03-17T20:57:27.179986Z",
"resource_uri": "",
"server_modified_on": "2020-03-17T20:57:27.382548Z",
"type": "data",
"uiversion": "1",
"version": "1"
}
This is probably because of #type inside form.
The # character can't be used in RTDB paths.
See How data is structured from the docs.
Keys cannot contain
.
$
#
[
]
/
ASCII control characters 0-31 or 127
I integrated Jenkins with my node project.
While building the project on Jenkins, I want to update my node config variables using Jenkins environment variables.
Here is my template config file.
{
"aws": {
"s3": {
"base_url": "AWS_S3_BASE_URL",
"bucket": "AWS_S3_BUCKET",
"region": "AWS_S3_REGION",
"accessKeyId": "AWS_S3_ACCESS_KEY",
"secretAccessKey": "AWS_S3_SECRET_ACCESS_KEY"
}
},
"db": {
"sequelize": {
"dialect": "postgres",
"logging": true,
"database": "DB_DATABASE",
"port": 5432,
"minConnections": 1,
"maxConnections": 4,
"maxIdleTime": 1000,
"write": {
"endpoint": "DB_HOST",
"username": "DB_USER",
"password": "DB_PASSWORD"
},
"read": [
{
"endpoint": "DB_HOST",
"username": "DB_USER",
"password": "DB_PASSWORD"
}
]
}
}
}
How can I update these variables using Jenkins environment variables?
Thanks in advance!
I am very new to loopback. I am making my first app with it and I change my datasource to MySql. my person model look like this
person.json
{
"name": "Person",
"plural": "People",
"base":"User",
"properties": {
"firstName": {
"type": "string",
"required": true
},
"lastName": {
"type": "string",
"required": true
},
"username": {
"type": "string",
"required": true
},
"email": {
"type": "string",
"required": true
},
"password": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW",
"accessType": "*"
}
],
"methods": []
}
and
datasource.json
{
"db": {
"name": "db",
"connector": "memory"
},
"mysql": {
"host": "localhost",
"port": 3306,
"database": "demo",
"username": "demouser",
"password": "****",
"name": "mysql",
"connector": "mysql"
}
}
and
model-config.json
{
"_meta": {
"sources": [
"../common/models",
"./models"
]
},
"AccessToken": {
"dataSource": "db",
"public": false
},
"ACL": {
"dataSource": "db",
"public": false
},
"RoleMapping": {
"dataSource": "db",
"public": false
},
"Role": {
"dataSource": "db",
"public": false
},
"Person": {
"dataSource": "mysql",
"public": true
}
}
After this when I want to create any person I cant create any person as I am unauthorized. I inserted an entry in mysql and tried to login but no luck.But when I remove User as base of person then all goes fine. But I lose all auth features inherit from User. How can I extend User using mysql as datasource properly so that I can use Person as my Users?
Thanks in Advance
Can you try to add the following ACL?
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW",
"accessType": "*",
"property": "create"
}
],
You can debug the application using:
DEBUG=loopback:security:* node .