Skip to content

Commit

Permalink
Merge pull request #47 from palantir/import
Browse files Browse the repository at this point in the history
added scripts migrated from internal repo for public use
  • Loading branch information
mpanighetti authored Nov 15, 2024
2 parents d3c8535 + 1a6e8ae commit 7bba495
Show file tree
Hide file tree
Showing 9 changed files with 352 additions and 7 deletions.
40 changes: 40 additions & 0 deletions extension-attributes/Charger Wattage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

###
#
# Name: Charger Wattage.sh
# Description: Reports the wattage of the power adapter (if connected).
# Created: 2022-10-05
# Last Modified: 2024-11-15
# Version: 1.0.2
#
#
# Copyright 2022 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## main process ##########



# Report results.
echo "<result>$(/usr/sbin/system_profiler SPPowerDataType | /usr/bin/awk '/Wattage/ {print $NF}')</result>"



exit 0
6 changes: 3 additions & 3 deletions extension-attributes/Kernel Extensions (Third-Party).sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
###
#
# Name: Kernel Extensions (Third-Party).sh
# Description: Displays all third-party kernel extensions installed.
# Description: Displays all enabled third-party kernel extensions.
# Created: 2016-08-17
# Last Modified: 2024-05-30
# Version: 2.0
# Last Modified: 2024-11-15
# Version: 2.0.0.1
#
#
# Copyright 2016 Palantir Technologies, Inc.
Expand Down
40 changes: 40 additions & 0 deletions extension-attributes/Remote Login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

###
#
# Name: Remote Login.sh
# Description: Reports whether Remote Login is On or Off.
# Created: 2021-08-02
# Last Modified: 2024-11-15
# Version: 1.0.1
#
#
# Copyright 2021 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## main process ##########



# Report result.
echo "<result>$(/usr/sbin/systemsetup -getremotelogin | /usr/bin/awk '{print $NF}')</result>"



exit 0
39 changes: 39 additions & 0 deletions extension-attributes/Startup Volume.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/sh

###
#
# Name: Startup Volume.sh
# Description: Reports the name of the startup volume.
# Created: 2024-02-27
# Last Modified: 2024-11-15
# Version: 1.0.1
#
#
# Copyright 2024 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## main process ##########



echo "<result>$(/usr/sbin/diskutil info -plist "$(bless --getBoot)" | /usr/bin/plutil -extract VolumeName raw -- -)</result>"



exit 0
8 changes: 4 additions & 4 deletions extension-attributes/System Extensions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
###
#
# Name: System Extensions.sh
# Description: Lists all system extensions by running systemextensionsctl list.
# Description: Lists all enabled system extensions.
# Created: 2024-02-06
# Last Modified: 2024-05-30
# Version: 1.0.1
# Last Modified: 2024-11-15
# Version: 1.0.2
#
#
# Copyright 2024 Palantir Technologies, Inc.
Expand All @@ -33,7 +33,7 @@


# Report results.
echo "<result>$(/usr/bin/systemextensionsctl list)</result>"
echo "<result>$(/usr/bin/systemextensionsctl list | /usr/bin/awk '/ enabled/ {print $4}' | /usr/bin/sort)</result>"



Expand Down
57 changes: 57 additions & 0 deletions extension-attributes/VirtualBox Extension Packs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/sh

###
#
# Name: VirtualBox Extension Packs.sh
# Description: Reports whether any VirtualBox extension packs are installed.
# Created: 2019-12-17
# Last Modified: 2024-11-15
# Version: 1.0.3
#
#
# Copyright 2019 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## variable-ing ##########



VBoxManagePath="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
extpackCheck=""



########## main process ##########



if [ -e "$VBoxManagePath" ]; then
if [ "$("$VBoxManagePath" list extpacks | /usr/bin/awk '/Extension Packs/ {print $NF}')" -gt 0 ]; then
extpackCheck="installed"
fi
fi




echo "<result>${extpackCheck}</result>"



exit 0
40 changes: 40 additions & 0 deletions extension-attributes/Wi-Fi Network.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

###
#
# Name: Wi-Fi Network.sh
# Description: Displays the current Wi-Fi network for the default network adapter (en0).
# Created: 2024-10-17
# Last Modified: 2024-11-15
# Version: 1.0.1
#
#
# Copyright 2024 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## main process ##########



# Report results.
echo "<result>$(/usr/sbin/networksetup -getairportnetwork en0 2>"/dev/null" | /usr/bin/awk -F 'Current Wi-Fi Network: ' '{print $2}')</result>"



exit 0
73 changes: 73 additions & 0 deletions extension-attributes/dotnet Runtime Versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh

###
#
# Name: dotnet Runtime Versions.sh
# Description: Reports versions of all .NET runtimes installed.
# Created: 2021-08-04
# Last Modified: 2024-11-15
# Version: 1.1.2
#
#
# Copyright 2021 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## variable-ing ##########



loggedInUser=$(/usr/bin/stat -f%Su "/dev/console")
version=""



########## function-ing ##########



# Exits if root is the currently logged-in user, or no logged-in user is detected.
check_logged_in_user () {
if [ "$loggedInUser" = "root" ] || [ -z "$loggedInUser" ]; then
echo "Nobody is logged in, no action required."
exit 0
fi
}



########## main process ##########



# Check script prerequisites.
check_logged_in_user


# List .NET runtimes and get version strings.
if [ -e "/usr/local/share/dotnet/dotnet" ]; then
version=$(sudo -u "$loggedInUser" /usr/local/share/dotnet/dotnet --list-runtimes | /usr/bin/awk '/.NETCore.App/ {print $2}')
fi


# Report results.
echo "<result>${version}</result>"



exit 0
56 changes: 56 additions & 0 deletions scripts/Reset Osquery Database.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh

###
#
# Name: Reset Osquery Database.sh
# Description: Runs osqueryctl clean to reset the local database, then restarts the service.
# Created: 2020-08-19
# Last Modified: 2024-11-15
# Version: 1.0.1
#
#
# Copyright 2020 Palantir Technologies, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
###



########## variable-ing ##########



binaryPath="/usr/local/bin/osqueryctl"



########## main process ##########



# Reset Osquery database.
if [ -e "$binaryPath" ]; then
"$binaryPath" stop
"$binaryPath" clean
"$binaryPath" start
echo "Ran osqueryctl clean to reset the local database and restarted the service."
else
echo "❌ ERROR: osqueryctl binary not found at ${binaryPath}, unable to proceed."
exit 1
fi



exit 0

0 comments on commit 7bba495

Please sign in to comment.