Modify "View Member Email Addresses" Setting - google-admin-sdk

Is there a way to modify the "View Member Email Addresses" settings via the google admin API? From some cursory investigation this doesn't seem to be the case but I'd be happy to be proven wrong. Note that this setting is different than the existing whoCanViewMembership setting.

Right now this is not possible. The group settings documentation lists the available settings and "View Member Email Addresses" is not listed. There's no alternative API as far as I am aware.
{
"kind": "groupsSettings#groups",
"email": string,
"name": string,
"description": string,
"whoCanAdd": string,
"whoCanJoin": string,
"whoCanViewMembership": string,
"whoCanViewGroup": string,
"whoCanInvite": string,
"allowExternalMembers": string,
"whoCanPostMessage": string,
"allowWebPosting": string,
"primaryLanguage": string,
"maxMessageBytes": integer,
"isArchived": string,
"archiveOnly": string,
"messageModerationLevel": string,
"spamModerationLevel": string,
"replyTo": string,
"customReplyTo": string,
"includeCustomFooter": string,
"customFooterText": string,
"sendMessageDenyNotification": string,
"defaultMessageDenyNotificationText": string,
"showInGroupDirectory": string,
"allowGoogleCommunication": string,
"membersCanPostAsTheGroup": string,
"messageDisplayFont": string
"includeInGlobalAddressList": string,
"whoCanLeaveGroup": string,
"whoCanContactOwner": string,
}

Related

How to convert json property names from snake to camel case

I have a json document like so... and I'm trying to convert the property names (not values) from snake case to camel.
ex -
message_type_id to messageTypeId
and _id to id
and point_altitude to pointAltitude
{
"#version": "1",
"point_altitude": 530,
"_id": "3325",
"header": {
"raw_message": "",
"message_type_id": "ping_event"
}
}
I've tried find ((\w)[_]{1,1}([a-z]{1,1})) and replace $1\U$2
but that also changes the values as well. I've also tried using positive lookaheads by adding .+?(?=\:) to the end of the find but that stops finding any second underscores in the property names.
https://regex101.com/r/jK5mP3/14
Doing this with a single regex replace is possible but probably not the best choice. Try
(?<=[\w])(?:_([a-z]))([^_"]*+)(?!"\s)|"_([a-z]+)"
Demo
I would rather suggest parsing the JSON and simply iterate of the property names. Depending on your environment, you could use code or a library like camelize or a command-line tool like jd (e.g. this jd answer deals with a similar problem).

Nifi - Extracting Key Value pairs into new fields

With Nifi I am trying to use the ReplaceText processor to extract key value pairs.
The relevant part of the JSON file is the 'RuleName':
"winlog": {
"channel": "Microsoft-Windows-Sysmon/Operational",
"event_id": 3,
"api": "wineventlog",
"process": {
"pid": 1640,
"thread": {
"id": 4452
}
},
"version": 5,
"record_id": 521564887,
"computer_name": "SERVER001",
"event_data": {
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
},
"provider_guid": "{5790385F-C22A-43E0-BF4C-06F5698FFBD9}",
"opcode": "Info",
"provider_name": "Microsoft-Windows-Sysmon",
"task": "Network connection detected (rule: NetworkConnect)",
"user": {
"identifier": "S-1-5-18",
"name": "SYSTEM",
"domain": "NT AUTHORITY",
"type": "Well Known Group"
}
},
Within the ReplaceText processor I have this configuration
ReplaceText
"winlog.event_data.RuleName":"MitreRef=(.*),Technique=(.*),Tactic=(.*),Alert=(.*)"
"MitreRef":"$1","Technique":"$2","Tactic":"$3","Alert":"$4"
The first problem is that the new fields MitreRef etc. are not created.
The second thing is that the fields may appear in any order in the original JSON, e.g.
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
or,
MitreRef=1043,Tactic=Command and Control,Technique=Commonly Used Port
Any ideas on how to proceed?
Welcome to StackOverflow!
As your question is quite ambiqious I'll try to guess what you aimed for.
Replacing string value of "RuleName" with JSON representation
I assume that you want to replace the entry
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
with something along the lines of
"RuleName": {
"Technique": "Commonly Used Port",
"Tactic": "Command and Control",
"MitreRef": "1043"
}
In this case you can grab basically the whole line and assume you have three groups of characters, each consisting of
A number of characters that are not the equals sign: ([^=]+)
The equals sign =
A number of characters that are not the comma sign: ([^,]+)
These groups in turn are separated by a comma: ,
Based on these assumptions you can write the following RegEx inside the Search Value property of the ReplaceText processor:
"RuleName"\s*:\s*"([^=]+)=([^,]+),([^=]+)=([^,]+),([^=]+)=([^,]+)"
With this, you grab the whole line and build a group for every important data point.
Based on the groups you may set the Replacement Value to:
"RuleName": {
"${'$1'}": "${'$2'}",
"${'$3'}": "${'$4'}",
"${'$5'}": "${'$6'}"
}
Resulting in the above mentioned JSON object.
Some remarks
The RegEx assumes that the entry is on a single line and does NOT work when it is splitted onto multiple lines, e.g.
"RuleName":
"Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
The RegEx assumes the are exactly three "items" inside the value of RuleName and does NOT work with different number of "items".
In case your JSON file can grow larger you may try to avoid using the Entire text evaluation mode, as this loads the content into a buffer and routes the FlowFile to the failure output in case the file is to large. In that case I recommend you to use the Line-by-Line mode as seen in the attached image.
Allowing a fourth additional value
In case there might be a fourth additional value, you may adjust the RegEx in the Search Value property.
You can add (,([^=]+)=([^,]+))? to the previous expression, which roughly translated to:
( )? - match what is in the bracket zero or one times
, - match the character comma
([^=]+)=([^,]+) - followed by the group of characters as explaind above
The whole RegEx will look like this:
"RuleName"\s*:\s*"([^=]+)=([^,]+),([^=]+)=([^,]+),([^=]+)=([^,]+)(,([^=]+)=([^,]+))?"
To allow the new value to be used you have to adjust the replacement value as well.
You can use the Expression Language available in most NiFi processor properties to decide whether to add another item to the JSON object or not.
${'$7':isEmpty():ifElse(
'',
${literal(', "'):append(${'$8'}):append('": '):append('"'):append(${'$9'}):append('"')}
)}
This expression will look if the seventh RegEx group exists or not and either append an empty string or the found values.
With this modification included the whole replacement value will look like the following:
"RuleName": {
"${'$1'}": "${'$2'}",
"${'$3'}": "${'$4'}",
"${'$5'}": "${'$6'}"
${'$7':isEmpty():ifElse(
'',
${literal(', "'):append(${'$8'}):append('": '):append('"'):append(${'$9'}):append('"')}
)}
}
regarding multiple occurrences
The ReplaceText processor replaces all occurrences it finds where the RegEx matches. Using the settings provided in the last paragraph given the following example input
{
"event_data": {
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043,Foo=Bar"
},
"RuleName": "Technique=Commonly Used Port,Tactic=Command and Control,MitreRef=1043"
}
will result in the following:
{
"event_data": {
"RuleName": {
"Technique": "Commonly Used Port",
"Tactic": "Command and Control",
"MitreRef": "1043",
"Foo": "Bar"
}
},
"RuleName": {
"Technique": "Commonly Used Port",
"Tactic": "Command and Control",
"MitreRef": "1043"
}
}
example template
You may download a template I created that includes the above processor from gist.

Grunt: replace wildcard value when using grunt-text-replace

I'm no regex master, and I'm pretty sure a regex is what is needed in this instance.
I currently have a text replacement task like so:
configSeed: {
src: ['src/*/local/app-config.js'],
overwrite: true,
replacements: [
{
from: 'var CONFIG_SEED_STRING = null;',
to: 'var CONFIG_SEED_STRING = "{"some_stringified_dynamic_json":"values"}";'
}
]
}
Which works fine the first time the config file is saved, the above string is replaced.
However, as soon as the string is replaced, further changes to the config don't have a replacement applied because obviously null is no longer to be found.
null is where my wildcard value needs to be, and the value could be either null (initially) or subsequent replacing a valid JSON string instead.
If my assumption about a wildcard being needed is true, would that trigger recursion upon save? Or does Grunt have in-built protection against this situation? [edit: I've tested this by replacing the string with the same value, recursion does not occur.]
So, assuming it is safe to use a wildcard where I want to, could I please get help with a regex value to be replaced?
Alternative solutions also welcome, for example my code base is unchanging enough that I could viably replace a line of code completely, if that's possible.
Thanks for any help provided.
Omg, I actually did it, what a feeling. After some painful reading on regex again:
configSeed: {
src: ['src/*/local/app.js'],
overwrite: true,
replacements: [
{
from: /var CONFIG_SEED_STRING = '[^']*'/g,
to: 'var CONFIG_SEED_STRING = \'{"foo":"bar"}\''
},
{
from: 'var CONFIG_SEED_STRING = null',
to: 'var CONFIG_SEED_STRING = \'{"foo":"bar"}\''
}
]
}
Not perfect, because I have two from/tos, but it catches both null and valid JSON data in between single quoted String value for CONFIG_SEED_STRING.
Instant reward time for writing a regex! I'm allowing myself 15 minutes of Youtube at work.

mongo shell search for value like "/"fubak#drooop.com"/"

I may have let a bug loose on our code that essentially ruined some of our db data.
Every now and again we come across a username that has " " in his email so we need to fix this.
How can I search for a value like "/"fubak#drooop.com"/" in one field using my mongo shell?
I have been trying all the combinations I can think of like:
db.users.find(username: /"/" .* /)
and
db.users.find(username: //.*//)
or
db.users.find(username: /"".*/)
But nothing seems to work.
new RegExp('^".*')
This finds all the records that start with ".
Thanks.
Try this:
db.users.find({ email: "(?:[^\\"]+|\\.)* })
This will match all documents which contains quotes in the email
Not to sure which one is you problem, so the solutions to both possible scenarios with data in MongoDB like this:
{ "email" : "\"/\"fubak#drooop.com\"/\"" }
{ "email" : "/fubak#drooop.com/" }
{ "email": "\"blablabla#blip.ca\"" }
First document match:
db.problem.find({ email: /^\"/ })
Second document match:
db.problem.find({ email: /^\// })
Third document match
db.problem.find({ email: /^\"/ })
Do not know what you mean otherwise by "having quotes" as that is not valid JSON and by extension is also invalid BSON.

How to extract everything between 2 characters from JSON response?

I'm using the regex in Jmeter 2.8 to extract some values from JSON responses.
The response is like that:
{
"key": "prod",
"id": "p2301d",
"objects": [{
"id": "102955",
"key": "member",
...
}],
"features":"product_features"
}
I'm trying to get everything except the text between [{....}] with one regex.
I've tried this one "key":([^\[\{.*\}\],].+?) but I'm always getting the other values between [{...}] (in this example: member)
Do you have any clue?
Thanks.
Suppose you can try to use custom JSON utils for jmeter (JSON Path Assertion, JSON Path Extractor, JSON Formatter) - JSON Path Extractor in this case.
Add ATLANTBH jmeter-components to jmeter: https://github.com/ATLANTBH/jmeter-components#installation-instructions.
Add JSON Path Extractor (from Post Processors components list) as child to the sampler which returns json response you want to process:
(I've used Dummy Sampler to emulate your response, you will have your original sampler)
Add as many extractors as values your want to extract (3 in this case: "key", "id", "features").
Configure each extractor: define variable name to store extracted value and JSONPath query to extract corresponding value:
for "key": $.key
for "id": $.id
for "features": $.features
Further in script your can refer extracted values using jmeter variables (variable name pointed in JSON Path Extractor settings in "Name" field): e.g. ${jsonKey}, ${jsonID}, ${$.features}.
Perhaps it may be not the most optimal way but it works.
My solution for my problem was to turn the JSON into an object so that i can extract just the value that i want, and not the values in the {...}.
Here you can see my code:
var JSON={"itemType":"prod","id":"p2301d","version":"10","tags":[{"itemType":"member","id":"p2301e"},{"itemType":"other","id":"prod10450"}],"multiPrice":null,"prices":null};
//Transformation into an object:
obj = eval(JSON );
//write in the Jmeter variable "itemtype", the content of obj.itemType:prod
vars.put("itemtype", obj.itemType);
For more information: http://www.havecomputerwillcode.com/blog/?p=500.
A general solution: DEMO
Regex: (\[{\n\s*(?:\s*"\w+"\s*:\s*[^,]+,)+\n\s*}\])
Explanation, you don't consume the spaces that you must correctly, before each line there are spaces and you must consume them before matching, that's why isn't your regex really working. You don't need to scape the { char.