├── docker └── netframework │ ├── shared │ ├── contrast_security.yaml │ ├── startDefaultAppPool.ps1 │ └── startCustomAppPool.ps1 │ ├── Dockerfile-CustomAppPool │ └── Dockerfile-DefaultAppPool ├── README.md ├── azure-app-service-site-extension └── appdeploy.json ├── auto-update └── netframework │ └── AutoUpdate.ps1 └── LICENSE /docker/netframework/shared/contrast_security.yaml: -------------------------------------------------------------------------------- 1 | # For full instructions on yaml configuration: 2 | # https://docs.contrastsecurity.com/installation-netconfig.html 3 | api: 4 | url: https://teamserver-dotnet.contsec.com 5 | api_key: 6 | service_key: 7 | user_name: 8 | -------------------------------------------------------------------------------- /docker/netframework/Dockerfile-CustomAppPool: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 2 | 3 | # Install the site 4 | ADD ${site_root} /inetpub/wwwroot 5 | 6 | # Add the startup script 7 | ADD startCustomAppPool.ps1 C:\shared\startCustomAppPool.ps1 8 | # Add the contrast config yaml file (optional) 9 | ADD contrast_security.yaml c:\shared\contrast_security.yaml 10 | 11 | # Setup Contrast .NET Agent and start the site 12 | ENTRYPOINT [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; /shared/startCustomAppPool.ps1" ] 13 | -------------------------------------------------------------------------------- /docker/netframework/Dockerfile-DefaultAppPool: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 2 | 3 | # Install the site 4 | ADD ${site_root} /inetpub/wwwroot 5 | 6 | # Add the startup script 7 | ADD startDefaultAppPool.ps1 C:\shared\startDefaultAppPool.ps1 8 | # Add the contrast config yaml file (optional) 9 | ADD contrast_security.yaml c:\shared\contrast_security.yaml 10 | 11 | # Setup Contrast .NET Agent and start the site 12 | ENTRYPOINT [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; /shared/startDefaultAppPool.ps1" ] 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # contrast-dotnet-examples 2 | 3 | Example code snippets and scripts to complement documentation for Contrast .NET Agents. 4 | 5 | Current examples in this repo: 6 | 7 | * [*auto-update/netframework/AutoUpdate.ps1*](auto-update/netframework/AutoUpdate.ps1): Scripted installation or update of the .NET Framework agent. 8 | 9 | * [*docker/netframework/Dockerfile-DefaultAppPool*](docker/netframework/Dockerfile-DefaultAppPool): Running the .NET Framework agent in a Docker container in the default AppPool 10 | 11 | * [*docker/netframework/Dockerfile-CustomAppPool*](docker/netframework/Dockerfile-CustomAppPool): Running the .NET Framework agent in a Docker container with a custom AppPool 12 | 13 | * [*azure-app-service-site-extension/appdeploy.json*](azure-app-service-site-extension/appdeploy.json): 14 | Azure ARM template for deploying a .NET Framework application as an _Azure App Service Web App_ using the Contrast .NET Agent Site Extension. 15 | 16 | 17 | >We will accept pull requests in this repo for more enhancements and use cases -------------------------------------------------------------------------------- /docker/netframework/shared/startDefaultAppPool.ps1: -------------------------------------------------------------------------------- 1 | #Remove any staging files from previous runs of the container 2 | if(Test-Path "C:\run") { 3 | Remove-Item -Recurse -Force "C:\run" 4 | } 5 | # Create staging folder for contrast files 6 | New-Item "C:\run\" -ItemType Directory -ErrorAction SilentlyContinue > $null 7 | 8 | # Download the latest contrast agent assemblies from Nuget.org 9 | Invoke-WebRequest "https://www.nuget.org/api/v2/package/Contrast.NET.Azure.AppService/" -OutFile c:\run\contrastAgent.zip 10 | Expand-Archive C:\run\contrastAgent.zip -DestinationPath c:\run\contrastAgent 11 | 12 | # Copy the config yaml 13 | New-Item "C:\run\config" -ItemType Directory -ErrorAction SilentlyContinue > $null 14 | Copy-Item -Path C:\shared\contrast_security.yaml -Destination C:\run\config\contrast_security.yaml -Force 15 | 16 | ##### Set Required settings 17 | $env:COR_ENABLE_PROFILING = "1" 18 | $env:COR_PROFILER = "{EFEB8EE0-6D39-4347-A5FE-4D0C88BC5BC1}" 19 | $env:COR_PROFILER_PATH_32 = "C:\run\contrastAgent\content\contrastsecurity\ContrastProfiler-32.dll" 20 | $env:COR_PROFILER_PATH_64 = "C:\run\contrastAgent\content\contrastsecurity\ContrastProfiler-64.dll" 21 | 22 | #### Contrast Configuration 23 | # Set path to config file. Remove if not using the yaml file, or if the yaml is in the default location (C:\ProgramData\contrast\dotnet\contrast_security.yaml) 24 | $env:CONTRAST_CONFIG_PATH = "C:\run\config\contrast_security.yaml" 25 | 26 | # Alternately you can also use environment variables instead of configuration yaml file. 27 | # They can be set here or passed in with "docker run -e" 28 | # For example contrast.url becomes CONTRAST__URL. More documentation: https://docs.contrastsecurity.com/installation-netconfig.html#environment-variables 29 | 30 | # Minimum required settings for Contrast authentication: 31 | #$env:CONTRAST__API__URL = "https://app.contrastsecurity.com" 32 | #$env:CONTRAST__API__USER_NAME = "my_user_name" 33 | #$env:CONTRAST__API__SERVICE_KEY = "service_key" 34 | #$env:CONTRAST__API__API_KEY = "api_key" 35 | 36 | # Microsoft's ServiceMonitor process will restart IIS and shutdown when the IIS service shuts down. 37 | # It will also add the environment variables set above to the DefaultAppPool process. 38 | C:\ServiceMonitor.exe w3svc 39 | -------------------------------------------------------------------------------- /docker/netframework/shared/startCustomAppPool.ps1: -------------------------------------------------------------------------------- 1 | #Remove any staging files from previous runs of the container 2 | if(Test-Path "C:\run") { 3 | Remove-Item -Recurse -Force "C:\run" 4 | } 5 | # Create staging folder for contrast files 6 | New-Item "C:\run\" -ItemType Directory -ErrorAction SilentlyContinue > $null 7 | 8 | # Download the latest contrast agent assemblies from Nuget.org 9 | Invoke-WebRequest "https://www.nuget.org/api/v2/package/Contrast.NET.Azure.AppService/" -OutFile c:\run\contrastAgent.zip 10 | Expand-Archive C:\run\contrastAgent.zip -DestinationPath c:\run\contrastAgent 11 | 12 | # Copy the config yaml 13 | New-Item "C:\run\config" -ItemType Directory -ErrorAction SilentlyContinue > $null 14 | Copy-Item -Path C:\shared\contrast_security.yaml -Destination C:\run\config\contrast_security.yaml -Force 15 | 16 | # Setup required environment variables to set on the appPool 17 | $envVars = @{ 18 | "COR_ENABLE_PROFILING" = "1"; 19 | "COR_PROFILER" = "{EFEB8EE0-6D39-4347-A5FE-4D0C88BC5BC1}"; 20 | "COR_PROFILER_PATH_32" = "C:\run\contrastAgent\content\contrastsecurity\ContrastProfiler-32.dll"; 21 | "COR_PROFILER_PATH_64" = "C:\run\contrastAgent\content\contrastsecurity\ContrastProfiler-64.dll"; 22 | "CONTRAST_CONFIG_PATH" = "C:\run\config\contrast_security.yaml"; 23 | } 24 | 25 | 26 | $appcmdExe = "$env:windir\System32\inetsrv\appcmd.exe" 27 | $appPool = "CustomAppPool" 28 | 29 | # (Re)Create appPool 30 | & $appcmdExe delete apppool /name:"""$appPool""" > $null 31 | & $appcmdExe add apppool /name:"""$appPool""" 32 | 33 | # Set Environment variables on the app pool 34 | foreach($envVarKey in $envVars.Keys) { 35 | $envVarValue = $envVars[$envVarKey] 36 | Write-Host "Setting env on $($appPool): $envVarKey, $envVarValue" 37 | 38 | & $appcmdExe set config -section:system.applicationHost/applicationPools /-"[name='$appPool'].environmentVariables.[name='$envVarKey']" /commit:apphost > $null 39 | & $appcmdExe set config -section:system.applicationHost/applicationPools /+"[name='$appPool'].environmentVariables.[name='$envVarKey',value='$envVarValue']" /commit:apphost 40 | } 41 | # Set the new app pool on our app 42 | & $appcmdExe set app "Default Web Site/" /applicationPool:"""$appPool""" 43 | 44 | # The ServiceMonitor process will restart IIS and exit when the IIS service shuts down. 45 | C:\ServiceMonitor.exe w3svc -------------------------------------------------------------------------------- /azure-app-service-site-extension/appdeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "sites_name": { 6 | "defaultValue": "webgoat-dotnet-pm-template", 7 | "type": "string" 8 | } 9 | }, 10 | "variables": { 11 | }, 12 | "resources": [ 13 | { 14 | "type": "Microsoft.Web/sites", 15 | "apiVersion": "2018-11-01", 16 | "name": "[parameters('sites_name')]", 17 | "location": "East US", 18 | "kind": "app", 19 | "properties": { 20 | "siteConfig": { 21 | "appSettings": [ 22 | { 23 | "name": "CONTRAST__API__API_KEY", 24 | "value": "", 25 | "slotSetting": false 26 | }, 27 | { 28 | "name": "CONTRAST__API__SERVICE_KEY", 29 | "value": "", 30 | "slotSetting": false 31 | }, 32 | { 33 | "name": "CONTRAST__API__URL", 34 | "value": "", 35 | "slotSetting": false 36 | }, 37 | { 38 | "name": "CONTRAST__API__USER_NAME", 39 | "value": "", 40 | "slotSetting": false 41 | }, 42 | { 43 | "name": "CONTRAST__APPLICATION__METADATA", 44 | "value": " OPTIONAL", 45 | "slotSetting": false 46 | }, 47 | { 48 | "name": "CONTRAST__APPLICATION__GROUP", 49 | "value": " OPTIONAL", 50 | "slotSetting": false 51 | }, 52 | { 53 | "name": "CONTRAST__APPLICATION__NAME", 54 | "value": " OPTIONAL", 55 | "slotSetting": false 56 | } 57 | ] 58 | } 59 | }, 60 | "resources": [ 61 | { 62 | "name": "Contrast.NET.Azure.SiteExtension", 63 | "type": "siteextensions", 64 | "apiVersion": "2018-11-01", 65 | "dependsOn": [ 66 | "[resourceId('Microsoft.Web/Sites', parameters('sites_name'))]" 67 | ] 68 | } 69 | ] 70 | } 71 | ] 72 | } -------------------------------------------------------------------------------- /auto-update/netframework/AutoUpdate.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | * Copyright (c) 2019, Contrast Security, Inc. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, are 6 | * permitted provided that the following conditions are met: 7 | * 8 | * Redistributions of source code must retain the above copyright notice, this list of 9 | * conditions and the following disclaimer. 10 | * 11 | * Redistributions in binary form must reproduce the above copyright notice, this list of 12 | * conditions and the following disclaimer in the documentation and/or other materials 13 | * provided with the distribution. 14 | * 15 | * Neither the name of the Contrast Security, Inc. nor the names of its contributors may 16 | * be used to endorse or promote products derived from this software without specific 17 | * prior written permission. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 24 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 27 | * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ################### Contrast.NET Agent Automated Install and Configuration Example Script ############ 29 | #> 30 | <# 31 | .SYNOPSIS 32 | This script will download the latest available Contrast.NET Agent and install it. If the agent is already installed, 33 | it will be upgraded. Authentication settings will be taken from the existing installation or parameters of this script 34 | .DESCRIPTION 35 | If Contrast.NET Agent is already installed, this script will use the Contrast UI authentication settings from 36 | its yaml config file, or DotnetAgentService.config file (for older agents). If these files are not available 37 | or no agent is installed, then the authentication settings below must be passed in as the following parameters. 38 | .PARAMETER ApiUrl 39 | Url for Contrast UI (api.url). Defaults to https://app.contrastsecurity.com if not provided 40 | .PARAMETER ApiKey 41 | Api Key for Contrast UI (api.api_key) 42 | .PARAMETER ServiceKey 43 | Service Key for Contrast UI (api.service_key) 44 | .PARAMETER ApiUserName 45 | Username of Contrast UI (api.user_name) 46 | #> 47 | 48 | Param( 49 | [Parameter(Mandatory=$false)] 50 | [string] $ApiUrl, 51 | [Parameter(Mandatory=$false)] 52 | [string] $ApiKey, 53 | [Parameter(Mandatory=$false)] 54 | [string] $ServiceKey, 55 | [Parameter(Mandatory=$false)] 56 | [string] $ApiUserName 57 | ) 58 | # Helper function. See below for main script 59 | function GetXmlConfigSetting($xmlDoc, $configKey) 60 | { 61 | $appSettings = $xmlDoc.configuration.appSettings 62 | $configElement = $appSettings.add | Where-Object{ $_.key -eq $configKey } | Select-Object -first 1 63 | if($null -ne $configElement ) { 64 | return $configElement.value 65 | } 66 | else { 67 | return $null 68 | } 69 | } 70 | 71 | $authSettingsProvided = ($ApiKey -and $ApiUserName -and $ServiceKey) 72 | # Get install folder 73 | $contrastReg = Get-ItemProperty "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Contrast Security, Inc.\Contrast.NET\" -ErrorAction SilentlyContinue -ErrorVariable ProcessError 74 | if(($null -eq $contrastReg) -and (!$authSettingsProvided)) { 75 | Write-Host -ForegroundColor Yellow "Contrast.NET is not installed. Please pass in the ApiKey, ApiUserName and ServiceKey parameters" 76 | exit 77 | } 78 | # if contrast is already installed, try to get authentication settings from it 79 | if($contrastReg -and !$authSettingsProvided) { 80 | $version = $contrastReg.Version 81 | $installDirectory = $contrastReg.InstallDirectory 82 | $dataDirectory = $contrastReg.DataDirectory 83 | Write-Host "Contrast.NET $version is currently installed" 84 | # get settings from yaml file 85 | if(!$ApiUrl -or !$ApiKey -or !$ApiUserName -or !$ServiceKey) { 86 | $yamlPath = "$dataDirectory\contrast_security.yaml" 87 | $oldConfigPath = "$installDirectory\DotnetAgentService.exe.config" 88 | if(Test-Path $yamlPath) { 89 | Write-Host "Getting authentication settings from yaml config at $yamlPath" 90 | $ApiUrl = Select-String -Path $yamlPath -Pattern "^\W+url: (.+)" | % { $_.Matches[0].Groups[1].Value } 91 | $ApiKey = Select-String -Path $yamlPath -Pattern "^\W+api_key: (.+)" | % { $_.Matches[0].Groups[1].Value } 92 | $ServiceKey = Select-String -Path $yamlPath -Pattern "^\W+service_key: (.+)" | % { $_.Matches[0].Groups[1].Value } 93 | $ApiUserName = Select-String -Path $yamlPath -Pattern "^\W+user_name: (.+)" | % { $_.Matches[0].Groups[1].Value } 94 | } 95 | elseif(Test-Path $oldConfigPath) { 96 | Write-Host "Getting authentication settings from service config at $oldConfigPath" 97 | $configXml = [xml](Get-Content $oldConfigPath) 98 | $ApiUrl = GetXmlConfigSetting $configXml "TeamServerUrl" 99 | $ApiKey = GetXmlConfigSetting $configXml "TeamServerApiKey" 100 | $ServiceKey = GetXmlConfigSetting $configXml "TeamServerServiceKey" 101 | $ApiUserName = GetXmlConfigSetting $configXml "TeamServerUserName" 102 | } 103 | } 104 | } 105 | if(!$ApiKey -or !$ApiUserName -or !$ServiceKey) { 106 | Write-Host "Could not determine Contrast authentication settings. Please provide them using the ApiUrl, ApiKey, ApiUserName and ServiceKey parameters" 107 | exit 108 | } 109 | if(!$ApiUrl) { 110 | $ApiUrl = "https://app.contrastsecurity.com" 111 | } 112 | # some old agents still put /Contrast in the url in the config file 113 | elseif($ApiUrl.Contains("/Contrast")) { 114 | $ApiUrl = $ApiUrl.Substring(0, $ApiUrl.IndexOf("/Contrast")) 115 | } 116 | 117 | Write-Host "Api Url: $ApiUrl 118 | ApiKey: $ApiKey 119 | ServiceKey: $ServiceKey 120 | ApiUserName: $ApiUserName" 121 | 122 | #1. Download the agent from TeamServer 123 | # Make temporary directory 124 | # where the agent will be downloaded. 125 | $tempName = [System.IO.Path]::GetRandomFileName() 126 | $DestinationPath = (Join-Path $env:TEMP $tempName) 127 | 128 | New-Item -ItemType Directory -Path $DestinationPath | Out-Null 129 | Write-Host "Creating temporary directory for agent download: $DestinationPath" 130 | 131 | #Download the agent 132 | $enc = [system.Text.Encoding]::ASCII 133 | $authToken = [System.Convert]::ToBase64String($enc.GetBytes($ApiUserName + ":" + $ServiceKey)) 134 | $wc = New-Object System.Net.WebClient 135 | # Required for use with web SSL sites 136 | [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 137 | $wc.Headers.Add("Authorization", $authToken) 138 | $wc.Headers.Add("API-Key", $ApiKey) 139 | $wc.Headers.Add("Accept", "application/json") 140 | $resource = "$ApiUrl/Contrast/s/api/engine/download/dotnet" 141 | $agentFile = "$DestinationPath\ContrastSetup.zip" 142 | Write-Host "Downloading agent installer..." 143 | $wc.DownloadFile($resource, $agentFile) 144 | 145 | #2. Extract the agent 146 | $AgentPath = "$DestinationPath\ContrastSetup.exe" 147 | Add-Type -AssemblyName System.IO.Compression.FileSystem 148 | Write-Host "Extracting agent from downloaded zip" 149 | [System.IO.Compression.ZipFile]::ExtractToDirectory($agentFile, $DestinationPath) 150 | 151 | #3. Install the agent 152 | Write-Host "Installing Contrast.NET Agent: $AgentPath -s -norestart PathToYaml=$DestinationPath\contrast_security.yaml SUPPRESS_RESTARTING_IIS=0 INSTALL_AGENT_EXPLORER=1 INSTALL_UPGRADE_SERVICE=1 StartTray=0" 153 | # This is a silent install so no GUI will be shown 154 | # To avoid UAC prompts, make sure this script is run in an administrative console 155 | Start-Process -FilePath $AgentPath -ArgumentList "-s -norestart PathToYaml=$DestinationPath\contrast_security.yaml SUPPRESS_RESTARTING_IIS=0 INSTALL_AGENT_EXPLORER=1 INSTALL_UPGRADE_SERVICE=1 StartTray=0" -Wait 156 | 157 | #Cleanup the temporary directory 158 | Write-Host "Clearing temporary directory $DestinationPath" 159 | Remove-Item $DestinationPath -Recurse 160 | 161 | # Display install status 162 | $contrastReg = Get-ItemProperty "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Contrast Security, Inc.\Contrast.NET\" -ErrorAction SilentlyContinue -ErrorVariable ProcessError 163 | if($contrastReg) { 164 | $version = $contrastReg.Version 165 | Write-Host "Contrast.NET $version has been installed." 166 | } 167 | else { 168 | Write-Host -ForegroundColor Red "Contrast.NET was not installed. Please check the error messages or install manually" 169 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Attribution-NonCommercial-ShareAlike 4.0 International 2 | 3 | ======================================================================= 4 | 5 | Creative Commons Corporation ("Creative Commons") is not a law firm and 6 | does not provide legal services or legal advice. Distribution of 7 | Creative Commons public licenses does not create a lawyer-client or 8 | other relationship. Creative Commons makes its licenses and related 9 | information available on an "as-is" basis. Creative Commons gives no 10 | warranties regarding its licenses, any material licensed under their 11 | terms and conditions, or any related information. Creative Commons 12 | disclaims all liability for damages resulting from their use to the 13 | fullest extent possible. 14 | 15 | Using Creative Commons Public Licenses 16 | 17 | Creative Commons public licenses provide a standard set of terms and 18 | conditions that creators and other rights holders may use to share 19 | original works of authorship and other material subject to copyright 20 | and certain other rights specified in the public license below. The 21 | following considerations are for informational purposes only, are not 22 | exhaustive, and do not form part of our licenses. 23 | 24 | Considerations for licensors: Our public licenses are 25 | intended for use by those authorized to give the public 26 | permission to use material in ways otherwise restricted by 27 | copyright and certain other rights. Our licenses are 28 | irrevocable. Licensors should read and understand the terms 29 | and conditions of the license they choose before applying it. 30 | Licensors should also secure all rights necessary before 31 | applying our licenses so that the public can reuse the 32 | material as expected. Licensors should clearly mark any 33 | material not subject to the license. This includes other CC- 34 | licensed material, or material used under an exception or 35 | limitation to copyright. More considerations for licensors: 36 | wiki.creativecommons.org/Considerations_for_licensors 37 | 38 | Considerations for the public: By using one of our public 39 | licenses, a licensor grants the public permission to use the 40 | licensed material under specified terms and conditions. If 41 | the licensor's permission is not necessary for any reason--for 42 | example, because of any applicable exception or limitation to 43 | copyright--then that use is not regulated by the license. Our 44 | licenses grant only permissions under copyright and certain 45 | other rights that a licensor has authority to grant. Use of 46 | the licensed material may still be restricted for other 47 | reasons, including because others have copyright or other 48 | rights in the material. A licensor may make special requests, 49 | such as asking that all changes be marked or described. 50 | Although not required by our licenses, you are encouraged to 51 | respect those requests where reasonable. More_considerations 52 | for the public: 53 | wiki.creativecommons.org/Considerations_for_licensees 54 | 55 | ======================================================================= 56 | 57 | Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International 58 | Public License 59 | 60 | By exercising the Licensed Rights (defined below), You accept and agree 61 | to be bound by the terms and conditions of this Creative Commons 62 | Attribution-NonCommercial-ShareAlike 4.0 International Public License 63 | ("Public License"). To the extent this Public License may be 64 | interpreted as a contract, You are granted the Licensed Rights in 65 | consideration of Your acceptance of these terms and conditions, and the 66 | Licensor grants You such rights in consideration of benefits the 67 | Licensor receives from making the Licensed Material available under 68 | these terms and conditions. 69 | 70 | 71 | Section 1 -- Definitions. 72 | 73 | a. Adapted Material means material subject to Copyright and Similar 74 | Rights that is derived from or based upon the Licensed Material 75 | and in which the Licensed Material is translated, altered, 76 | arranged, transformed, or otherwise modified in a manner requiring 77 | permission under the Copyright and Similar Rights held by the 78 | Licensor. For purposes of this Public License, where the Licensed 79 | Material is a musical work, performance, or sound recording, 80 | Adapted Material is always produced where the Licensed Material is 81 | synched in timed relation with a moving image. 82 | 83 | b. Adapter's License means the license You apply to Your Copyright 84 | and Similar Rights in Your contributions to Adapted Material in 85 | accordance with the terms and conditions of this Public License. 86 | 87 | c. BY-NC-SA Compatible License means a license listed at 88 | creativecommons.org/compatiblelicenses, approved by Creative 89 | Commons as essentially the equivalent of this Public License. 90 | 91 | d. Copyright and Similar Rights means copyright and/or similar rights 92 | closely related to copyright including, without limitation, 93 | performance, broadcast, sound recording, and Sui Generis Database 94 | Rights, without regard to how the rights are labeled or 95 | categorized. For purposes of this Public License, the rights 96 | specified in Section 2(b)(1)-(2) are not Copyright and Similar 97 | Rights. 98 | 99 | e. Effective Technological Measures means those measures that, in the 100 | absence of proper authority, may not be circumvented under laws 101 | fulfilling obligations under Article 11 of the WIPO Copyright 102 | Treaty adopted on December 20, 1996, and/or similar international 103 | agreements. 104 | 105 | f. Exceptions and Limitations means fair use, fair dealing, and/or 106 | any other exception or limitation to Copyright and Similar Rights 107 | that applies to Your use of the Licensed Material. 108 | 109 | g. License Elements means the license attributes listed in the name 110 | of a Creative Commons Public License. The License Elements of this 111 | Public License are Attribution, NonCommercial, and ShareAlike. 112 | 113 | h. Licensed Material means the artistic or literary work, database, 114 | or other material to which the Licensor applied this Public 115 | License. 116 | 117 | i. Licensed Rights means the rights granted to You subject to the 118 | terms and conditions of this Public License, which are limited to 119 | all Copyright and Similar Rights that apply to Your use of the 120 | Licensed Material and that the Licensor has authority to license. 121 | 122 | j. Licensor means the individual(s) or entity(ies) granting rights 123 | under this Public License. 124 | 125 | k. NonCommercial means not primarily intended for or directed towards 126 | commercial advantage or monetary compensation. For purposes of 127 | this Public License, the exchange of the Licensed Material for 128 | other material subject to Copyright and Similar Rights by digital 129 | file-sharing or similar means is NonCommercial provided there is 130 | no payment of monetary compensation in connection with the 131 | exchange. 132 | 133 | l. Share means to provide material to the public by any means or 134 | process that requires permission under the Licensed Rights, such 135 | as reproduction, public display, public performance, distribution, 136 | dissemination, communication, or importation, and to make material 137 | available to the public including in ways that members of the 138 | public may access the material from a place and at a time 139 | individually chosen by them. 140 | 141 | m. Sui Generis Database Rights means rights other than copyright 142 | resulting from Directive 96/9/EC of the European Parliament and of 143 | the Council of 11 March 1996 on the legal protection of databases, 144 | as amended and/or succeeded, as well as other essentially 145 | equivalent rights anywhere in the world. 146 | 147 | n. You means the individual or entity exercising the Licensed Rights 148 | under this Public License. Your has a corresponding meaning. 149 | 150 | 151 | Section 2 -- Scope. 152 | 153 | a. License grant. 154 | 155 | 1. Subject to the terms and conditions of this Public License, 156 | the Licensor hereby grants You a worldwide, royalty-free, 157 | non-sublicensable, non-exclusive, irrevocable license to 158 | exercise the Licensed Rights in the Licensed Material to: 159 | 160 | a. reproduce and Share the Licensed Material, in whole or 161 | in part, for NonCommercial purposes only; and 162 | 163 | b. produce, reproduce, and Share Adapted Material for 164 | NonCommercial purposes only. 165 | 166 | 2. Exceptions and Limitations. For the avoidance of doubt, where 167 | Exceptions and Limitations apply to Your use, this Public 168 | License does not apply, and You do not need to comply with 169 | its terms and conditions. 170 | 171 | 3. Term. The term of this Public License is specified in Section 172 | 6(a). 173 | 174 | 4. Media and formats; technical modifications allowed. The 175 | Licensor authorizes You to exercise the Licensed Rights in 176 | all media and formats whether now known or hereafter created, 177 | and to make technical modifications necessary to do so. The 178 | Licensor waives and/or agrees not to assert any right or 179 | authority to forbid You from making technical modifications 180 | necessary to exercise the Licensed Rights, including 181 | technical modifications necessary to circumvent Effective 182 | Technological Measures. For purposes of this Public License, 183 | simply making modifications authorized by this Section 2(a) 184 | (4) never produces Adapted Material. 185 | 186 | 5. Downstream recipients. 187 | 188 | a. Offer from the Licensor -- Licensed Material. Every 189 | recipient of the Licensed Material automatically 190 | receives an offer from the Licensor to exercise the 191 | Licensed Rights under the terms and conditions of this 192 | Public License. 193 | 194 | b. Additional offer from the Licensor -- Adapted Material. 195 | Every recipient of Adapted Material from You 196 | automatically receives an offer from the Licensor to 197 | exercise the Licensed Rights in the Adapted Material 198 | under the conditions of the Adapter's License You apply. 199 | 200 | c. No downstream restrictions. You may not offer or impose 201 | any additional or different terms or conditions on, or 202 | apply any Effective Technological Measures to, the 203 | Licensed Material if doing so restricts exercise of the 204 | Licensed Rights by any recipient of the Licensed 205 | Material. 206 | 207 | 6. No endorsement. Nothing in this Public License constitutes or 208 | may be construed as permission to assert or imply that You 209 | are, or that Your use of the Licensed Material is, connected 210 | with, or sponsored, endorsed, or granted official status by, 211 | the Licensor or others designated to receive attribution as 212 | provided in Section 3(a)(1)(A)(i). 213 | 214 | b. Other rights. 215 | 216 | 1. Moral rights, such as the right of integrity, are not 217 | licensed under this Public License, nor are publicity, 218 | privacy, and/or other similar personality rights; however, to 219 | the extent possible, the Licensor waives and/or agrees not to 220 | assert any such rights held by the Licensor to the limited 221 | extent necessary to allow You to exercise the Licensed 222 | Rights, but not otherwise. 223 | 224 | 2. Patent and trademark rights are not licensed under this 225 | Public License. 226 | 227 | 3. To the extent possible, the Licensor waives any right to 228 | collect royalties from You for the exercise of the Licensed 229 | Rights, whether directly or through a collecting society 230 | under any voluntary or waivable statutory or compulsory 231 | licensing scheme. In all other cases the Licensor expressly 232 | reserves any right to collect such royalties, including when 233 | the Licensed Material is used other than for NonCommercial 234 | purposes. 235 | 236 | 237 | Section 3 -- License Conditions. 238 | 239 | Your exercise of the Licensed Rights is expressly made subject to the 240 | following conditions. 241 | 242 | a. Attribution. 243 | 244 | 1. If You Share the Licensed Material (including in modified 245 | form), You must: 246 | 247 | a. retain the following if it is supplied by the Licensor 248 | with the Licensed Material: 249 | 250 | i. identification of the creator(s) of the Licensed 251 | Material and any others designated to receive 252 | attribution, in any reasonable manner requested by 253 | the Licensor (including by pseudonym if 254 | designated); 255 | 256 | ii. a copyright notice; 257 | 258 | iii. a notice that refers to this Public License; 259 | 260 | iv. a notice that refers to the disclaimer of 261 | warranties; 262 | 263 | v. a URI or hyperlink to the Licensed Material to the 264 | extent reasonably practicable; 265 | 266 | b. indicate if You modified the Licensed Material and 267 | retain an indication of any previous modifications; and 268 | 269 | c. indicate the Licensed Material is licensed under this 270 | Public License, and include the text of, or the URI or 271 | hyperlink to, this Public License. 272 | 273 | 2. You may satisfy the conditions in Section 3(a)(1) in any 274 | reasonable manner based on the medium, means, and context in 275 | which You Share the Licensed Material. For example, it may be 276 | reasonable to satisfy the conditions by providing a URI or 277 | hyperlink to a resource that includes the required 278 | information. 279 | 3. If requested by the Licensor, You must remove any of the 280 | information required by Section 3(a)(1)(A) to the extent 281 | reasonably practicable. 282 | 283 | b. ShareAlike. 284 | 285 | In addition to the conditions in Section 3(a), if You Share 286 | Adapted Material You produce, the following conditions also apply. 287 | 288 | 1. The Adapter's License You apply must be a Creative Commons 289 | license with the same License Elements, this version or 290 | later, or a BY-NC-SA Compatible License. 291 | 292 | 2. You must include the text of, or the URI or hyperlink to, the 293 | Adapter's License You apply. You may satisfy this condition 294 | in any reasonable manner based on the medium, means, and 295 | context in which You Share Adapted Material. 296 | 297 | 3. You may not offer or impose any additional or different terms 298 | or conditions on, or apply any Effective Technological 299 | Measures to, Adapted Material that restrict exercise of the 300 | rights granted under the Adapter's License You apply. 301 | 302 | 303 | Section 4 -- Sui Generis Database Rights. 304 | 305 | Where the Licensed Rights include Sui Generis Database Rights that 306 | apply to Your use of the Licensed Material: 307 | 308 | a. for the avoidance of doubt, Section 2(a)(1) grants You the right 309 | to extract, reuse, reproduce, and Share all or a substantial 310 | portion of the contents of the database for NonCommercial purposes 311 | only; 312 | 313 | b. if You include all or a substantial portion of the database 314 | contents in a database in which You have Sui Generis Database 315 | Rights, then the database in which You have Sui Generis Database 316 | Rights (but not its individual contents) is Adapted Material, 317 | including for purposes of Section 3(b); and 318 | 319 | c. You must comply with the conditions in Section 3(a) if You Share 320 | all or a substantial portion of the contents of the database. 321 | 322 | For the avoidance of doubt, this Section 4 supplements and does not 323 | replace Your obligations under this Public License where the Licensed 324 | Rights include other Copyright and Similar Rights. 325 | 326 | 327 | Section 5 -- Disclaimer of Warranties and Limitation of Liability. 328 | 329 | a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE 330 | EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS 331 | AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF 332 | ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, 333 | IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, 334 | WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR 335 | PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, 336 | ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT 337 | KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT 338 | ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. 339 | 340 | b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE 341 | TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, 342 | NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, 343 | INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, 344 | COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR 345 | USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN 346 | ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR 347 | DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR 348 | IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. 349 | 350 | c. The disclaimer of warranties and limitation of liability provided 351 | above shall be interpreted in a manner that, to the extent 352 | possible, most closely approximates an absolute disclaimer and 353 | waiver of all liability. 354 | 355 | 356 | Section 6 -- Term and Termination. 357 | 358 | a. This Public License applies for the term of the Copyright and 359 | Similar Rights licensed here. However, if You fail to comply with 360 | this Public License, then Your rights under this Public License 361 | terminate automatically. 362 | 363 | b. Where Your right to use the Licensed Material has terminated under 364 | Section 6(a), it reinstates: 365 | 366 | 1. automatically as of the date the violation is cured, provided 367 | it is cured within 30 days of Your discovery of the 368 | violation; or 369 | 370 | 2. upon express reinstatement by the Licensor. 371 | 372 | For the avoidance of doubt, this Section 6(b) does not affect any 373 | right the Licensor may have to seek remedies for Your violations 374 | of this Public License. 375 | 376 | c. For the avoidance of doubt, the Licensor may also offer the 377 | Licensed Material under separate terms or conditions or stop 378 | distributing the Licensed Material at any time; however, doing so 379 | will not terminate this Public License. 380 | 381 | d. Sections 1, 5, 6, 7, and 8 survive termination of this Public 382 | License. 383 | 384 | 385 | Section 7 -- Other Terms and Conditions. 386 | 387 | a. The Licensor shall not be bound by any additional or different 388 | terms or conditions communicated by You unless expressly agreed. 389 | 390 | b. Any arrangements, understandings, or agreements regarding the 391 | Licensed Material not stated herein are separate from and 392 | independent of the terms and conditions of this Public License. 393 | 394 | 395 | Section 8 -- Interpretation. 396 | 397 | a. For the avoidance of doubt, this Public License does not, and 398 | shall not be interpreted to, reduce, limit, restrict, or impose 399 | conditions on any use of the Licensed Material that could lawfully 400 | be made without permission under this Public License. 401 | 402 | b. To the extent possible, if any provision of this Public License is 403 | deemed unenforceable, it shall be automatically reformed to the 404 | minimum extent necessary to make it enforceable. If the provision 405 | cannot be reformed, it shall be severed from this Public License 406 | without affecting the enforceability of the remaining terms and 407 | conditions. 408 | 409 | c. No term or condition of this Public License will be waived and no 410 | failure to comply consented to unless expressly agreed to by the 411 | Licensor. 412 | 413 | d. Nothing in this Public License constitutes or may be interpreted 414 | as a limitation upon, or waiver of, any privileges and immunities 415 | that apply to the Licensor or You, including from the legal 416 | processes of any jurisdiction or authority. 417 | 418 | ======================================================================= 419 | 420 | Creative Commons is not a party to its public licenses. 421 | Notwithstanding, Creative Commons may elect to apply one of its public 422 | licenses to material it publishes and in those instances will be 423 | considered the "Licensor." Except for the limited purpose of indicating 424 | that material is shared under a Creative Commons public license or as 425 | otherwise permitted by the Creative Commons policies published at 426 | creativecommons.org/policies, Creative Commons does not authorize the 427 | use of the trademark "Creative Commons" or any other trademark or logo 428 | of Creative Commons without its prior written consent including, 429 | without limitation, in connection with any unauthorized modifications 430 | to any of its public licenses or any other arrangements, 431 | understandings, or agreements concerning use of licensed material. For 432 | the avoidance of doubt, this paragraph does not form part of the public 433 | licenses. 434 | 435 | Creative Commons may be contacted at creativecommons.org. --------------------------------------------------------------------------------