Skip to content

Instantly share code, notes, and snippets.

View doshyt's full-sized avatar
🏠

Igor Andriushchenko doshyt

🏠
View GitHub Profile
@doshyt
doshyt / npm-find-package.sh
Last active November 9, 2021 19:03
One-liner to find all versions of a given package in node_modules of multiple repos. Add the list of folders to scan as TARGETS and the name of a culprit package - i.e. "rc".
CULPRIT="rc"; TARGETS=( "awesome-repo-1" "awesome-repo-2" ); for element in "${TARGETS[@]}"; do echo "Checking $element"; find $element/node_modules -path "*/$CULPRIT/**" -prune -name "package.json" -exec cat {} + | grep -e \"version\": -e _location ; done
@doshyt
doshyt / trivyScan.sh
Last active July 15, 2021 09:32
Run Trivy scan from dockerimage with mounting .trivyignore file
#!/bin/bash
imageRepository="python"
version="3.4-alpine"
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/.trivyignore:/tmp/.trivyignore \
aquasec/trivy image \
--ignorefile /tmp/.trivyignore \
--no-progress --exit-code 1 \
${imageRepository}:${version}
@doshyt
doshyt / getBinariesVersions.ps1
Last active February 15, 2019 16:02
Script to record versions of all binaries from the folder and subfolders to a CSV file. Useful to produce component lists in software builds.
$targetPath = "."
$candidateBin = @()
$candidateBin += Get-ChildItem -Path $targetPath -Recurse -Include *.dll,*.exe -Exclude *Nunit*,*test* |
ForEach-Object {
try {
$_ | Add-Member NoteProperty FileVersion ($_.VersionInfo.FileVersion)
} catch {}
$_
} | Select-Object BaseName,FileVersion
@doshyt
doshyt / Install-OmsAgent.ps1
Created October 1, 2018 22:04
Installs OMS agent from the ZIP archive that is created of the unpacked agent MSI
Param(
[string]$AgentDownloadUrl="http://127.0.0.1/omsagent.zip",
[string]$WorkspaceId,
[string]$WorkspaceKey
)
try {
Write-Host "Downloading OMS agent"
Invoke-WebRequest -Uri $AgentDownloadUrl -OutFile omsagent.zip
Write-Host "Extracting OMS agent"
Add-Type -AssemblyName System.IO.Compression.FileSystem
netsh advfirewall firewall add rule name = SQLPort dir = in protocol = tcp action = allow localport = 1433 remoteip = 10.0.0.0/16 profile = PUBLIC
@doshyt
doshyt / Get-UserAdGroups.ps1
Created July 24, 2017 09:29
One-liner for getting user group membership from AD
Import-Module ActiveDirectory; Get-ADPrincipalGroupMembership $(Get-AdUser -f {SamAccountNAme -like 'XXXYYY'})