-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
126 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Validate | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
validate: | ||
name: Validate code | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install | ||
run: | | ||
npm ci | ||
- name: Build | ||
run: | | ||
npm run build | ||
- name: Changed files | ||
id: changed-files | ||
uses: tj-actions/changed-files@v45 | ||
|
||
- name: List changed files | ||
env: | ||
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} | ||
run: | | ||
for file in ${CHANGED_FILES}; do | ||
node build/validate.js $file | ||
done | ||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
|
||
- name: Build | ||
run: | | ||
GOOS=windows GOARCH=386 go build -o ./ghaction-virustotal-win32.exe -v -ldflags "-s -w" | ||
GOOS=windows GOARCH=amd64 go build -o ./ghaction-virustotal-win64.exe -v -ldflags "-s -w" | ||
- name: VirusTotal Scan | ||
uses: crazy-max/ghaction-virustotal@v4 | ||
with: | ||
vt_api_key: ${{ secrets.VT_API_KEY }} | ||
request_rate: 4 | ||
files: cat downloads/log.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { | ||
apiBuffer, | ||
dirCreate, | ||
dirExists, | ||
fileCreate, | ||
fileExists, | ||
fileReadString, | ||
pathGetExt, | ||
PluginFile, | ||
PluginFiles, | ||
} from '@studiorack/core'; | ||
import { validatePluginYaml } from './sources/local.js'; | ||
import chalk from 'chalk'; | ||
import path from 'path'; | ||
|
||
const DIR_DOWNLOADS = 'downloads'; | ||
const DIR_LOG = path.join(DIR_DOWNLOADS, 'log.txt'); | ||
|
||
const filepath: string = process.argv[2]; | ||
const ext: string = pathGetExt(filepath); | ||
|
||
if (ext === 'yaml') { | ||
// Ensure directory and log file exist | ||
if (!dirExists(DIR_DOWNLOADS)) dirCreate(DIR_DOWNLOADS); | ||
if (!fileExists(DIR_LOG)) fileCreate(DIR_LOG, ''); | ||
|
||
// Validate the schema and fields | ||
const { plugin } = validatePluginYaml(filepath); | ||
let log: string = fileReadString(DIR_LOG); | ||
|
||
// Download files and compare | ||
for (const type in plugin.files) { | ||
const pluginFile: PluginFile = plugin.files[type as keyof PluginFiles]; | ||
const pluginFileName: string = path.basename(pluginFile.url); | ||
const pluginFileBuffer: Buffer | void = await apiBuffer(pluginFile.url); | ||
const pluginFileLocalPath: string = path.join(DIR_DOWNLOADS, pluginFileName); | ||
if (pluginFile.size === pluginFileBuffer.length) { | ||
console.log(chalk.green(`✓ ${pluginFile.url}`)); | ||
} else { | ||
console.log(chalk.red(`X ${pluginFile.url} size needs updating to ${pluginFileBuffer.length}`)); | ||
} | ||
// Add file to log for virus scanning | ||
fileCreate(pluginFileLocalPath, pluginFileBuffer); | ||
log += pluginFileLocalPath + '\n'; | ||
} | ||
fileCreate(DIR_LOG, log); | ||
} |