How do I know who changed my Cloud Function - firebase

Yesterday, on a beautiful Saturday, I was resting. When suddenly the phone rings and the "system has stopped working".
When I observed the "cloud functions" one of them had an upload that I did not do, probably another member of the team.
After all, I was resting!
Now, my manager wants the deployment history for all functions.
How to know and where to get this information?
Entering the "cloud function" I can even see that there was the deploy, but it does not say "which user did it".

There are audit logs kept for all user actions. You can determine who updated the function by:
Go to Logging > Logs Explorer
In the Query Builder text box, add the following search term:
protoPayload.methodName="google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
Click the Run Query button and then filter down by the date and time of when it was deployed and you'll see the user's email in the principal_email property.

#Brian's answer is good. But here's another way to check Audit logs and see all operations happening on Cloud Functions:
Go to Navigation Menu > Home > Activity
Go to Filter Categories on the right part of the screen and make sure all Activity types are selected (checking only Data Access and configuration works fine as well).
Click Resource type and uncheck all but don't click OK yet.
Type to filter "Cloud Function" then check it.
Click OK.

In logs for the functions you have the information about deployment it should look something like that:
{"#type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{},"authenticationInfo":{"principalEmail":"EMAIL#gmail.com"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/ffunctions-nodejs/locations/us-central1/functions/CRON_1440_OptimisationCall"}
I would start with reviewing this information (it is on the Console -> Project -> Functions -> logs)
Down the rabbit hole, we can go into console.cloud.google.com (Console -> Project -> Functions -> click on the three dots and go "Detailed usage statistics").
not really sure what you can dig in there though

Go to the Logs explorer and paste the below to find the updaed users of the cloud function.
resource.type = "cloud_function"
resource.labels.function_name = "your_cloud_function_name"
protoPayload.methodName="google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
Hope this helps!!

Related

Send HTTP request when a computer is added to Active Directory

I'm going to start working with Active Directory (first time in my life) with python ldap3 library. I've searched the internet for a while but couldn't find any solution for my question. I want to send a request when a computer is added to AD. I've found this event that might solve my problem but I've no idea what is this or how can I use this for my problem.
Thanks for answers.
That is an event in the Windows Security Event Log on the domain controller.
Windows does allow you to trigger a scheduled task on an event. To do what you want to do, you could set up a scheduled task on each domain controller.
In Task Scheduler:
Click "Create Task"
Click the "Triggers" tab, then "New..."
For "Begin the task", select "On an event"
In "Log", select "Security, and for "Event ID" put "4741"
Click "OK"
Then on the "Actions" tab is where you tell it what you want it to do when that event happens. You can run anything you want. You can write a PowerShell script if you want. Just search Google for "run PowerShell script from scheduled task" if that's the way you want to go.

Google Cloud Function logs showing error icon for Info log types

I am new to google-cloud and to stack driver logging. deployed a python script as cloud function also enabled in-built logging for python. I had set multiples logs based on the execution.
logging.info("Cloud fucntion was Triggerred on time {}".format(datetime.utcnow()))
While viewing in cloud function logs, i see many, like even the statement above, for which I have set INFO as the log level is displayed with !! icon which according to the legends should be displayed for only error types.
As I am new to this stack-driver logging, I am not sure of the reason, can anyone please explain? Thanks.

Newly Created Firebase Functions Throwing UNAUTHENTICATED Error

I have a Firebase project with over 10 cloud functions. Today I added 3 more, but all three of the new ones are throwing an error UNAUTHENTICATED without actually trying to hit the function. (There's no record of a function call in the logs). I haven't made any changes to my environment or Firebase project since adding the previous functions.
I have tried redeploying all of the functions in my project, the three newest ones continue to fail while the previous ones work fine. I have also verified that I am using Node 8, since there are some similar issues reported stemming from using Node 10. I am not sure what else to try since the issue only applies to the new functions.
The new functions all have a similar signature:
exports.createGroup = functions.https.onCall((data, context) => {
//Firestore access
});
They are being called like this:
const create = functions().httpsCallable('createGroup');
return create({ group: oGroup }).then(result => {
//Do something
}).catch(err => {
console.log(err.message); //UNAUTHENTICATED
});
Node Version: 8.16.2
Firebase Tools Version: 7.6.1
2023 UPDATE
1. Go to the Google Cloud Console:
2. Click the checkbox next to the function to which you want to grant
access.
3. Click Permissions at the top of the screen. The Permissions panel
opens.
4. Click Add principal.
5. In the New principals field, type allUsers
6. Select the role Cloud Functions > Cloud Functions Invoker from the
Select a role drop-down menu.
7. Click Save.
It must be solved at your GCP Console (not Firebase). Just follow these steps:
Go to your GCP Console and login
On the top menu, select the corresponding Firebase project
On the left menu go to Cloud Functions Click the checkbox of your function (not the name of the function)
Once selected, on the right menu select "Add member"
On "New member" type allUsers
On the Select function bar, select Cloud Functions -> Cloud functions invoker
Click on "Save" and then "Allow public access" on the pop-up warning
And you're good to go!
Via Google Cloud docs:
As of January 15, 2020, HTTP functions require authentication by
default. You can specify whether a function allows unauthenticated
invocation at or after deployment.
The solution was to utilize the Google Cloud console (NOT the Firebase console) to add the allUsers permission to the newly created functions.
https://cloud.google.com/functions/docs/securing/managing-access-iam#allowing_unauthenticated_function_invocation
I ran into this error when deploying several functions and there was an issue during the upload where it seems the deployment got corrupted .. perhaps network related, not sure
After deleting the offending cloud functions in the Firebase console, and then doing a fresh successful deploy for them, the "FirebaseFunctionsException UNAUTHENTICATED" error went away
First I tried to just redeploy the functions, but that was not enough, the error continued this way
From the documentation for 2nd gen Cloud Functions:
Go to the Google Cloud console
Click the linked name of the function to which you want to grant access.
Click the Powered By Cloud Run link in the top right corner of the Function details overview page.
Click Trigger and select Allow unauthenticated invocations.
Click Save.
Took me forever to find this after trying to add allUsers and getting "Principals of type allUsers and allAuthenticatedUsers cannot be added to this resource".

Why is Bing Custom Search API throwing an error when I make a call through node-js?

I was using Bing Custom Search API for the past week with no problems thanks to the free trial, but today, I tried upgrading to the S1 plan, since the API was sending error messages. I tried regenerating the key as well, but despite doing both of these things, I was still getting errors and unable to use the API.
However, I was able to make calls using: https://www.customsearch.ai/applications, where I was able to use my API key to test endpoints and get the results I expected. What baffles me is that my nodejs code which hasn't been modified aside from the subscription key should still work with the upgraded plan, but it doesn't.
I should be able to help here. Let us do little bit of troubleshooting once:
First go to https://www.customsearch.ai/applications -> click on your instance name ->Click on "Production" tab on top -> Try making API call on this page by providing Query and Subscription key you got. If this works, go to the next step.
On the page mentioned above you would have seen Custom Configuration ID and Subscription Key. Make sure those two are same in your node.js code. Ideally this should work.
If it still doesn't work, please share your error code so that I can get better understanding of the error you are getting.

Print Management / AIF

I have setup the AIF so that when an invoice is created, it gets added to the queue. I know that this doesn't work when Printing to Screen. So I had adjusted the print management settings for that customer to Print to Archive. However, the document still doesn't get added to the AIF queue.
After some investigation, I've found out why. Even though I have "Use Print Management" ticked in the Posting box for posting an Invoice, Under the Printer Setup I have "Send To" set to screen still, when I change this to Print Archive my document gets added to the AIF queue.
So my question is, why is this the case? Why doesn't it pick up what I have set in Print Management for that customer?
I attempted to recreate your issue, but it worked for me just as you would have expected. Perhaps your customer print management isn't set up correctly.
To change my test customer's print management settings, I went to the customer in the customer master form, click Setup -> Print management. Expanded Module -> Account -> Documents -> Sales order invoice. Right-clicked on Original and clicked Override. Then I overrode the default printer destination for that customer.
Follow those steps if you haven't already, and let me know if that works. If not, there may be some other problem.
Are your printers configured as AOS printers? See Classes\SalesFormLetter\checkAOSPrintersPrintManagement
Does this have the same issues in your test environments? Try resetting your usage data. There is a usePrintManagement variable packed in the invoicing process.
If you can debug this, it should be fairly easy to step through and see if print management is actually getting used.

Resources