While following the Introduction to APIs in Google lab, I'm facing an issue while creating a storage bucket. I followed the instructions but still the following is shown:
Run the following command to create a Cloud Storage bucket:
curl -X POST --data-binary #values.json
-H "Authorization: Bearer $OAUTH2_TOKEN"
-H "Content-Type: application/json"
"https://www.googleapis.com/storage/v1/b?project=$PROJECT_ID"
Error:
{
"error": {
"code": 400,
"message": "Invalid bucket name: '\u003cqwiklabs-gcp-00-eb5dde0a1183-bucket'",
"errors": [
{
"message": "Invalid bucket name: '\u003cqwiklabs-gcp-00-eb5dde0a1183-bucket'",
"domain": "global",
"reason": "invalid"
}
]
}
}
1.Edit the values.json file
nano values.json
{ "name": "quicklab-test-your-bucket",
"location": "us",
"storageClass": "multi_regional"
}
2.Get the token:
gcloud auth print-access-token
3.Set the variables:
export OAUTH2_TOKEN=your-token
export PROJECT_ID=your-project-id
4.Create the bucket:
curl -X POST --data-binary #values.json \
-H "Authorization: Bearer $OAUTH2_TOKEN" \
-H "Content-Type: application/json" \
"https://www.googleapis.com/storage/v1/b?project=$PROJECT_ID"
5.You should receive similar output:
{
"kind": "storage#bucket",
"id": "qwiklabs-test-bucket",
"selfLink": "https://www.googleapis.com/storage/v1/b/sean123456789",
"projectNumber": "218136653205",
"name": "sean123456789",
"timeCreated": "2018-10-19T21:04:03.604Z",
"updated": "2018-10-19T21:04:03.604Z",
"metageneration": "1",
"location": "US",
"storageClass": "MULTI_REGIONAL",
"etag": "CAE="
}
Related
I'm trying to execute remote command from Wazuh manager to the agent using API, below waht i'm trying to do:
curl -k -X PUT "https://192.168.1.76:55000/active-response?agents_list=001" -H "Authorization: Bearer $TOKEN" -H "content-type: application/json" -d '{"command": "customA", "custom":true}'
and then the response:
{"data": {"affected_items": ["001"], "total_affected_items": 1, "total_failed_items": 0, "failed_items": []}, "message": "AR command was sent to all agents", "error": 0}
The problem is simply that the command "customA" isn't triggered in the agent.
Here the body of the "/var/ossec/etc/ossec.conf" file in the MANAGER:
<command>
<name>customA</name>
<executable>launcher.cmd</executable>
<extra_args>custom_remove.py</extra_args>
</command>
<command>
<name>customB</name>
<executable>launcher.cmd</executable>
<extra_args>custom_remove.py</extra_args>
</command>
<command>
<name>forRemote</name>
<executable>custom_remove.exe</executable>
</command>
<active-response>
<disabled>no</disabled>
<command>customA</command>
<location>local</location>
<rules_id>255001</rules_id>
</active-response>
<active-response>
<disabled>no</disabled>
<command>customA</command>
<location>local</location>
<rules_id>999001</rules_id>
</active-response>
And this is the "local_internal_options.conf" file in the Windows AGENT 001:
windows.debug=2
rootcheck.sleep=0
syscheck.sleep=0
logcollector.remote_commands=1
wazuh_command.remote_commands=1
Eventually, I think that command and active response are correctly configured, because they will work correctly if i try to test them triggering a rule (for exampple rule 999001).
Moreover, i post the response of the api "GET /manager/configuration/analysis/command":
{
"data": {
"affected_items": [
{
"command": [
{
"name": "disable-account",
"executable": "disable-account",
"timeout_allowed": 1
},
{
"name": "restart-wazuh",
"executable": "restart-wazuh",
"timeout_allowed": 0
},
{
"name": "firewall-drop",
"executable": "firewall-drop",
"timeout_allowed": 1
},
{
"name": "host-deny",
"executable": "host-deny",
"timeout_allowed": 1
},
{
"name": "route-null",
"executable": "route-null",
"timeout_allowed": 1
},
{
"name": "win_route-null",
"executable": "route-null.exe",
"timeout_allowed": 1
},
{
"name": "netsh",
"executable": "netsh.exe",
"timeout_allowed": 1
},
{
"name": "customA",
"executable": "launcher.cmd",
"timeout_allowed": 0
},
{
"name": "customB",
"executable": "launcher.cmd",
"timeout_allowed": 0
},
{
"name": "forRemote",
"executable": "custom_remove.exe",
"timeout_allowed": 0
},
{
"name": "remove-threat",
"executable": "remove-threat.exe",
"timeout_allowed": 0
}
]
}
],
"total_affected_items": 1,
"total_failed_items": 0,
"failed_items": []
},
"message": "Active configuration was successfully read",
"error": 0
}
I hope that someone will help me. Thanks in advice!
please open C:\Program Files (x86)\ossec-agent\etc\shared\ar.conf file and verify that you have:
customA0 - launcher.cmd - 0
if you don't have it, create any file in /var/ossec/etc/shared/default/ for the manager to update the agent by sending a merged.mg, this resets the agent and updates it according to what you configured in ossec.conf from the manager.
The command should have customA0 instead of customA.
Example:
curl -k -X PUT "https://192.168.1.72:55000/active-response?agents_list=001" -H "Authorization: Bearer $(curl -u wazuh:wazuh -k -X GET "https://192.168 .1.xxx:55000/security/user/authenticate?raw=true)" -H "content-type: application/json" -d '{"command": "customA0", "custom":true}'
I hope this is useful.
Regards
Note: I attach an example that I did to test
manager
agent
Based on:
https://developers.google.com/drive/api/v3/push
I do not understand where to get the auth_token_for_current_user from.
I have service account credentials, also an OAuth token. I have tried the access_token, refresh_token... I do not understand what token this is supposed to be.
curl --location --request POST 'https://www.googleapis.com/drive/v3/changes/watch' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer 1//064ToBH1n***' \
--data-raw '{
"id":"***",
"type": "web_hook",
"address": "https://***.cloudfunctions.net/verify"
}'
returns:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Invalid Credentials",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Invalid Credentials"
}
}
Thanks for any help.
so I have this body of a CURL:
-d '{
"documentType": "SQMProjectFact",
"status": "published",
"selectAttributes": [
"Supplier"
],
"filterExpressions": [
{
"name": "createdDateFrom",
"field": "TimeCreated",
"op": ">=",
"defaultValue": "2018-08-05T01:01:59Z
" },
{
"name": "createdDateTo",
"field": "TimeCreated",
"op": "<=",
"defaultValue": "2018-08-15T01:01:59Z"
}
]
}'
When I run it on postman, it works tottaly fine, but when I try to do it on CMD, it keeps throwing me "Invalid body format".
I research and try chagning ' for ", and " for \", and a lot of conmbinations of that, erasing the spaces (just to see if it that solved it), but it stills throwing me that error.
Just for info, these are the headers:
-H "Authorization: Bearer xXxXXXxx-xxXx-xxxx-xxxx-xxxxxxxxxxxx"
-H "Content-Type: application/json"
-H "accept: application/json"
-H "apiKey: xxxxxxxxxxxxxxxxxxxxx"
Thanks for those who will reply!
curl -X POST -vv -H "Fiware-Service: myHome" -H "Fiware-ServicePath: /environment" -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"devices": [
{
"device_id": "0000000000000000",
"entity_name": "BedRoomSensor",
"entity_type": "multiSensor",
"attributes": [
{ "object_id": "t", "name": "Temperature", "type": "celsius" },
{ "object_id": "h", "name": "Humidity", "type": "degrees" }
]
}
]
} 'http://localhost:4041/iot/devices'
I execute the above curl commmand in order to provision my device.However it doesn't show anything and the command never ends.
What i missunderstood?
I have solved the problem following the first two steps of this guide:http://fiwaretourguide.readthedocs.io/en/latest/connection-to-the-internet-of-things/how-to-read-measures-captured-from-iot-devices/
In the step-by-step guide these steps weren't described.
In the second step i change the protocol fielde as "MQTT".
Now whenever i request the measures from my device i take the correct value.
I am trying to see how I can patch a Pod for OpenShift Via Rest by following the OpenShift Pod-Patch Rest Documentation. I have been able to post data with other apis from OpenShift such as Secret.
If I do curl call just to update the metadata name of a given pod:
curl -k \
-X PATCH \
-d #- \
-H "Authorization: Bearer $TOKEN" \
-H 'Accept: application/json' \
-H 'Content-Type: application/json-patch+json' \
$OPENSHIFT_URL/api/v1/namespaces/mytestproject/pods/app-1-build << 'EOF'
{
"kind": "Pod",
"apiVersion": "v1",
"metadata": {
"name": "app-2-build"
}
}
EOF
I get the response:
{
"kind": "Status",
"apiVersion": "v1",
"metadata": {},
"status": "Failure",
"message": "json: cannot unmarshal object into Go value of type jsonpatch.Patch",
"code": 500
}
I am unable to figure out what I am doing incorrect based on the schema, and the documentation at OpenShift for pod does not show examples of the json data schema in curl examples.