HiddenLayer Artifactory Model Security User Plugin
This plugin submits models downloaded from a HuggingFace repository to the HiddenLayer API for scanning. The plugin will block the download if the model is flagged as malicious.
For repositories that the plugin monitors, when a file is requested, it will submit it to HiddenLayer for scanning.
It will mark the the artifact in the repository with a property hiddenlayer.status
as either SAFE
or UNSAFE
.
This plugin is configurable and will work with both local and remote artifactory repositories. This plugin can also be configured to use the HiddenLayer SaaS platform or a self-hosted enterprise instance of the model scanning service.
This plugin needs to be added to the $ARTIFACTORY_HOME/etc/plugins
directory.
This can be done by copying the contentes of ./core/src
to the plugins directory.
The plugin can be configured by editing the hiddenlayer.properties
file in the $ARTIFACTORY_HOME/etc/plugins
directory.
The following configuartion options are available:
hiddenlayer.auth.url
- The URL for the HiddenLayer API. Required for SaaS, Optional for Enterprisehiddenlayer.auth.client_id
- The client ID for the HiddenLayer API. Required for SaaS, Optional for Enterprisehiddenlayer.auth.client_secret
- The client secret for the HiddenLayer API. Required for SaaS, Optional for Enterprisehiddenlayer.api.url
- The URL for the HiddenLayer API. Required. Change to the URL of your enterprise instance if using an enterprise instance.hiddenlayer.api.version
- The version of the HiddenLayer API. Required. Defaults tov2
hiddenlayer.scan.repo_ids
- A comma separated list of repository IDs to scan. Requiredhiddenlayer.scan.decision_missing
- The decision to make if thehiddenlayer.status
property is missing. Optional. Set todeny
orallow
.hiddenlayer.scan.missing_decision_retry
- If the scan cannot complete or fails during the intial request, this option will determine if the plugin will attempt to rescan the file. This may lead to excessive API calls. Optional. Set totrue
orfalse
. Defaults tofalse
.hiddenlayer.scan.delete_adhoc_models_after_scan
- If the plugin should delete the adhoc model from the HiddenLayer platform after the scan is complete. Note: This feature is only available against SaaS versions of the model scanner. Optional. Set totrue
orfalse
. Defaults totrue
.
Important
We use Devcontainers to provide a consistent IDE experience Please follow the IDE Bootstrap steps to ensure that you are running in a devcontainer.
- Install VSCode Extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
- cmd-shift-p -> "Dev Containers: Reopen In Container" (or click the blue array at the bottom-left corner)
gh auth login
gh auth setup-git
git config --global user.email "[username_here]@hiddenlayer.com" && git config --global user.name "[first_name] [last_name]"
To facilitate testing and setup, the following environment variables will be brought into the devcontainer environment:
- HL_CLIENT_ID - The client ID for the HiddenLayer API
- HL_CLIENT_SECRET - The client secret for the HiddenLayer API
- Start Artifactory Container
docker compose up
- Navigate to
localhost:8082
to see the- If prompted enter a new password. (i.e.
Fr0gg3r
)
- If prompted enter a new password. (i.e.
- Click on the banner to activate Artifactory.
- Enter a License and click
Save
. - Set up a new HuggingFace Repository
- Click on
Welcome
in the top right corner - Click on
New Remote Repository
- Select
HuggingFace
- Set the repository key (something like
hf
) - Click
Create Remote Repository
- Click on
- Configure the plugin
- Open the file
./core/src/hiddenlayer.properties
- Add your hiddenlayer API auth client_id and client_secret
- record the repository IDs for the repositories you want to scan
- Open the file
- Reload the plugin
curl -XPOST -uadmin:<password> localhost:8081/artifactory/api/plugins/reload
Now, whenever you download a model using the HuggingFace cli, the plugin will upload the model to the HiddenLayer API for scanning. Based on your configuration, the plugin will either block the download or allow it to proceed.
- Ensure the Artifactory container is running
docker compose up
- Run the tests
gradle clean
gradle artifactory_common
gradle modelscanner
The artifactory_common
set of tests will check the health of JFrog artifactory and install the license set in the environment variable HL_LICENSE_KEY
.
The modelscanner
set of tests will set up a remote huggingface repository and attempt to download a huggingface model from it.
The following environment variables can be configured and override the values in the core/src/hiddenlayer.properties
file:
- HL_CLIENT_ID - The client ID for the HiddenLayer API
- HL_CLIENT_SECRET - The client secret for the HiddenLayer API
- HL_LICENSE_KEY - The license key for JFrog Artifactory
- HL_API_URL - The URL for the HiddenLayer API