Using the Marathon REST API to update a configuration - marathon

Using cURL I want to modify the number of instances a group has by passing a json file to update the config. The way my groups are set up looks something like this:
'marathon > applications > topApp'
'marathon > applications > topApp > group1'
'marathon > applications > topApp > group2'
'marathon > applications > topApp > group3 , etc'
I only want to update group2 and cannot figure out how to specify it. I'm thinking of using 'PUT /v2/groups/{groupId}' which I got from the marathon rest api doc here https://mesosphere.github.io/marathon/docs/rest-api.html#example-5
Has anyone done this and can help? Is there a better way? This is my first time doing this. Thanks!

You can do curl -XPUT localhost:8080/v2/groups/path/to/group/group2 -d #group2.json where the content of group2.json contains the change of instance count.
If you only want to change the instance count of one single application you can also do something like this (might contain quotation problems):
curl -XPUT localhost:8080/v2/apps/path/to/app/app123 -d '{"instances":20}'

Related

Why are there tag keys missing when downloading OSM data to Postgis / Postgresql?

I'm working on a routing application using OSM data in pgrouting. I'm using overpass-api to access the data from a specific bounding box. However, after downloading the data, there seem to be tag_keys missing from the data.
When inspecting the data using postgis or QGIS, certain tag_keys are there, like "highway", "oneway" or "maxpeed". However, others seem to be missing. In particular the tag keys "bicycle" (with possible values like "yes" or "no") or "access" are not included in the data. These tag keys are available on OSM online, however.
The following code is used to retrieve the data from OSM through Overpass-API and put it into PGrouting
CITY="Utrecht_west"
BBOX="4.9926,52.0698,5.0772,52.1172"
wget --progress=dot:mega -O "$CITY.osm" "http://www.overpass-api.de/api/xapi?*[bbox=${BBOX}][#meta]"
OSM2pgrouting converter
cd ~/Desktop/Utrecht
osm2pgrouting \
-f Utrecht_west.osm \
-d utrecht_west \
-U user
I expect these lines to download all data in the bounding box, but some tag keys seem to be missing. What am I doing wrong here?
edit: it seems to be a similar issue to this post, however, I cannot find another answer to a similar issue
I'm not familiar with osm2pgrouting. However it looks like mapconfig.xml doesn't include "bicycle" and "access" tags. You either need to add them or create your own config file. If you want osm2pgrouting to consider these tags during routing this might not be enough, though.

List all files in a sub-folder in a given branch / tag

I have been spending the last couple of hours trying to figure out a way to reliably list all the files in a given git repo's sub-folder. For example, if I want to list all files under in the repo -
https://github.com/aws/aws-sdk-java
under the tag -
/tree/1.11.244
using the github api v3 or v4, could anyone please point me in the direction on the different steps to be done for this? Also, if we have a lot of files, is there a way I could add a file filter to look for a file pattern to list?
You need to pass the ref parameter when listing contents:
GET /repos/:owner/:repo/contents/:path?ref=:ref
And if you want it to be recursive you can use recursive=1
For example
GET /repos/user/my_repo/contents/tests/units?ref=0.1
If I want to see the files in tests/units under tag 0.1, with curl it would look like:
curl -u user:pass -X GET https://api.github.com/repos/user/my_repo/contents/tests/units?ref=0.1
Unfortunately I don't think you can add a query string to a request to this endpoint (also this endpoint has a maximum 1000 files to retrieve from a directory, if you have more you are going to need the Git Trees API)

How to get total error count from Klocwork automatically

I have a project running in Klocwork and after the build gets completed the Klocwork results will be generated. Every time I need to go to the Klocwork portal to get the results and look for the new issues or the total issues. Instead I need an API or script to get the total number of issues from the Klocwork results automatically when the build is successful.
Is there any way to achieve this? One way is to view the portal page source as html and get the result I need. However, I think there might be a better solution.
Can someone help me in achieving this?
Thanks in advance.
I answered a similar question over here. Below is an updated answer with links to the documentation for the most recent release, Klocwork 11.
Klocwork has a WebAPI which you can use to query this type of information from your favorite scripting language, or for example with curl. API documentation is also provided on your Klocwork server at http://klocwork_server_host:port/review/api, for example http://localhost:8080/review/api.
The query:
curl --data "action=search&user=my_account&project=my_project&query=build:build_1 status:Analyze state:New,Existing&ltoken=xxxx" http://localhost:8080/review/api
will return a list of all open (state New and Existing), non-cited (status Analyze) issues found in a build named build_1 of project my_project.
For a list of the keywords you can use in the query string with the search action, see Searching in Klocwork Review.
If you want just a summary of the number of defects instead of getting the whole list, you can use the report action:
curl --data "action=report&user=my_account&project=my_project&build:build_1&x=Category&y=Component&filterQuery=status:Analyze state:New,Existing&ltoken=xxxx" http://localhost:8080/review/api
which returns back a summary of the number of defects by checker category (taxonomy) and component. Sample output is below:
{"rows":[{"id":1,"name":"C and C++"},{"id":3,"name":"MISRA C"},{"id":4,"name":"MISRA C++"}],"columns":[{"id":5,"name":"System Model"}],"data":[[122],[354],[890]],"warnings":[]}
You can modify the x and y axis parameters to produce different breakdowns of the issues, for example by Severity and State instead:
curl --data "action=report&user=my_account&project=my_project&build:build_3&x=Severity&y=State&filterQuery=state:New,Existing,Fixed&ltoken=xxxx" http://localhost:8080/review/api
output:
{"rows":[{"id":1,"name":"Critical"},{"id":2,"name":"Error"},{"id":3,"name":"Warning"},{"id":4,"name":"Review"}],"columns":[{"id":-1,"name":"Existing"},{"id":-1,"name":"Fixed"},{"id":-1,"name":"New"}],"data":[[10,5,2],[20,6,1],[45,11,3],[1112,78,23]],"warnings":[]}
The WebAPI cookbook documentation has an example of using python with the report action and processing and formatting the response.

Specify parameters with SQLMAP

I'm a student learning php & mysql development. i have setup a private lab ( VM ) inside my computer to test & learn how sql injection works. When things get harder i use sqlmap to exploit and later on study the requests it made to my test app using verbose mode & by capturing packets via wireshark. I came across a small problem and that's to specify the parameter in a URL to sqlmap to test.
http://localhost/vuln/test.php?feature=music&song=1
i want sqlmap to scan the parameter song so i tried these solutions
-u http://localhost/vuln/test.php?feature=music&song=1 --skip feature
-u http://localhost/vuln/test.php? --data="feature=music&song=1" -p song
Tried different variations by adding and removing quotes and equal signs , non worked. I even tried setting the --risk to --level to its maximum but it still fails to pick up the last parameter.
I will be very thankful if an expert can help me out with this.
Thank you.
the p option can be used in the following way
-u "http://localhost/vuln/test.php?feature=music&song=1" -p song
I noticed also that you can scan multiple parameters using this :
-u "http://localhost/vuln/test.php?feature=music&song=1" -p 'song,feature'
This will scan the song parameter, then the feature parameter.
If sqlmap find a vulnerable parameter, it will ask you if you want to continue with the others.
You can simply add * to your value of parameter which you want to scan. Did you try that one?
I have this problem too. I think sqlmap inject the first parameter. If you type :
-u http://localhost/vuln/test.php?feature=music&song=1
sqlmap will inject 'feature' parameter. To make it inject 'song' parameter you need to reorder the parameter as follows :
-u http://localhost/vuln/test.php?song=1&feature=music
Dont forget to add '&' between each parameter. It worked for me.
I have already triggered this type of problem. You can simply skip the 'feature' parameter. E.g -u http:// localhost/vuln/test.php?feature=music&song=1 --skip=feature and then certainly it will start testing the 'song' parameter.

Export AD structure from specific OU, then re-create structure in new domain

I've researched and found the way to export our active directory information for our application is like this:
csvde -d OU=MyAppsOU,DC=dot,DC=testdmz,DC=lan
-f C:\temp\addump_ou.csv -r (objectClass=organizationalUnit)
Now, I've read that to do an import from that file, you just have to add the -i option to the line like this:
csvde -i -d OU=MyAppsOU-New,DC=dot,DC=newdmz,DC=lan
-f C:\temp\addump_ou.csv -r (objectClass=organizationalUnit)
Obviously, I'm very scared to try this as I don't want to blow away anything. My questions are:
Does specifying the OU=MyAppsOU-New create the new OU structure with that specific name? (I'm just trying to be 100% positive)
Does specifying the different domain name (newdmz) just update all of the data in the file to contain the new domains name?
or
Do I need to modify the exported csv file to change the domain name (testdmz) to what the new domain name will be (newdmz)?
Is there a different way I should be doing this?
I just want to re-create the OU structure without groups, roles (which are groups) and users. I will probably do those in a different process because we have different usernames for test and production.
Wow ! lost of question here, but according to me not enougth.
Begining by the end. CSVE.EXE is really not the exact tool I would use. As a Directorie developper I prefer LDIFDE.EXE, because it generates LDIF (LDAP data Interchange Format) which is more standard and more readable. You can also have a look to tools like ADAMSync.EXE that allow to synchronize two directories in AD world (but it's a big hammer for whant you want to do here)
Now choosing LDIFDE.EXE you will see that LDIF format is almost importable as is, but you nned to remove operational attributes (system attributes) from the file. The best way is to take them during the rxport. So you will use -L to only export the attributes you need or -O option to omit operational attributes.
To import in another domain, you will use -C option to change original domain part (DC=dot,DC=testdmz,DC=lan) by the new domain part.
Try it before in a virtual machine.