enable PUA protection in block mode for macOS - microsoft-graph-api

Hello everyone I have tried to run this script in Microsoft Intune to enable PUA protection in block mode for macOS. mdatp threat policy set --type potentially_unwanted_application --action block
but it failed it shows me that command not found, mdatp.
is there any alternative solutions?

Related

How do I make sure ports 8200..8299 for UIAutmator2 are free'd up after killing Appium?

I'm running Appium 24/7 on a Windows machine to perform automated tests. I'm running these tests via AVD on an emulator with Android 10. For my test, I give the correct Capabilities and runs functionally great. But after a few hours/days I get the follow error:
UnknownError: An unknown server-side error occurred while processing the command. Original error:*Cannot find any free port in range 8200..8299}. Please set the available port number by providing the systemPort capability or double check the processes that are locking ports within this range and terminate these which are not needed anymore at getResponseForW3CError at asyncHandler.
When my code is executed, I make sure the finally in try executes the AppiumDriverLocalService.stop(); method to kill Appium. My feeling says this does somehow not free up any ports for UIAutomator2 (which you can configure, but I have not configured, through systemPort capability.
} finally {
driver.closeApp();
service.stopServer();
System.exit(0);
}
Why does Appium not free up any ports for UIAutomator2 in the range 8000-8299 after stopping the service?
Android Debug Bridge version 1.0.40
Appium version 1.20.2
Android 10
PS I know of the adb command adb -s $UDID forward --remove-all but does this solve the real issue, I don't want to execute a Java Process each time
Update - Fix 2-3
I have fixed the issue by changing the finally clause to execute the following methods in order:
} finally {
AndroidDriver.quit();
AppiumDriverLocalService.stopServer();
In order to free up the port 8200..8299, AndroidDriver must be quit as UIAutomator2 is linked to this. The AppiumDriverLocalService will kill/forward/free this port and UIAutomator2, after this I can freely stop the server:
[ADB] Removing forwarded port socket connection: 8203
This issue is a good example of your problem. As you can see, Appium team is closing it as a Not A Bug.
Reason is obvious: Appium is not responsible for managing ports, it relies that your system has some free in required (by Appium code) range.
systemPort is used to connect to appium-uiautomator2-server, by default is 8200. Basically Appium selects one port from 8200 to 8299 for appium-uiautomator2-server. However, when you run tests in parallel, you must adjust the port to avoid conflicts. If you are not, you should be safe in 99% cases with the default.
Restart the system (assuming it will clear ports) and run tests. Check Appium server logs for any errors on closing session. It could be that issue is related to ADB setup or permission issue, and UI2 server is not stopped properly.
If so, port remains in use. And it is not Appium to deal with cleanup. I'm not sure that adb command you mentioned is a good 100% guaranteed way to do it.
I would just add a shell script that is executed before Appium server start to clean ports in 8200-8299 range and forget this problem.
killall -9 node - to kill all appium running internally and at root level
and adb kill-server - to kill the abd server by running this it resolved the above issue for me , hope may help someone

Geckodriver Selenium/Java not working on macOS Big Sur

I am using Selenium with Java and when i try to launch the Firefox browser using Geckodriver it says "“geckodriver” can’t be opened because Apple cannot check it for malicious software."
I've tried with spctl --add --label 'Approved' but it didn't work.
Does anyone have an idea?
Open "System Settings > Security & Privacy" immediately after trying to execute Gecko Driver, just after you receive the system pop-up claiming it is from an unidentified developer. The last program to be flagged for security issues should be available here (in this case, Gecko Driver).
Click on "Allow Anyway" and execute the program again. The security pop-up should appear again, this time with an "OK" button. Click on it and the driver should run.

How to append developer logs in a Dart CLI application

Dart natively supports a developer log function, which in Flutter automatically appends logging output to the device log.
But when I build a (server) CLI application in Dart, these logs appear to be only accessible via DevTools.
Where can I find the API to build a custom appender?
(Or is there already a Pub package that can append to console and/or rotating log files?)

Send command line argument/flag like '--relaxed-security' to saucelabs while initiating an appium session

I want to be able to execute certain adb shell commands on real devices in saucelabs.
I learned from https://wiki.saucelabs.com/display/DOCS/2019/02/13/Enhance+your+Appium+tests+on+emulators+with+ADB+commands that I can make use of '--relaxed-security' flag while initiating an appium session on saucelabs to execute adb shell commands.
While it is easier to pass command line arguments while starting appium on local machines, I'm not sure how to include the flag while connecting to saucelabs.
This is how I'm initiating a session on saucelabs :
desired_capabilities = {
"deviceName": "xxx",
"platformName": "xx",
"platformVersion": "xx",
"bundleId": "xxx",
"automationName": "uiautomator2",
"testobject_api_key" : "xxx"
}
driver = webdriver.Remote("https://us1-manual.app.testobject.com/wd/hub", desired_capabilities)
I assume it is enabled by default, you can double check your project to have Instrumentation option enabled.
Since it is a server flag, you can't pass it from client side and I don't see a way to do it via capability.
Try to run adb command and if it won't work - ask their support.
This has not been enabled in the Real Device Cloud of Sauce Labs so it will not work in this case
Update 20210825:
We've discussed the feature "ADB support for Android Real Devices" with our Product Team and they will investigate this from a technical perspective to see if this will be feasible. I'll keep you posted

Unable to toggle on and off location service using Appium

I need to enable and disable location service in Android before my test. I have tried the following solutions but nothing worked at all.
Scenario : 1
ADB commands
adb shell settings put secure location_providers_allowed +network,gps
adb shell settings put secure location_providers_allowed -network,gps
These commands working at times but not all the times so my test fails lot of times for disabling.
Scenario : 2
toggleLocationService() Method
public static void enableAndDisableLocation(AppiumDriver<WebElement> driver) {
((AndroidDriver<WebElement>) driver).openNotifications();
((AndroidDriver<WebElement>) driver).toggleLocationServices();
}
Are there any other solution to enable and disable Location service in Android using Appium. Also I want to know the status of the Location before enabling and disabling.
I am using Java client 5.0.4
Testing in Android Nougat.
To Enable:
adb shell settings put secure location_providers_allowed +gps
adb shell settings put secure location_providers_allowed +network
To Disable:
adb shell settings put secure location_providers_allowed -gps
adb shell settings put secure location_providers_allowed -network

Resources