Documentation Nexus IQ Server 1.18

Our documentation site has moved. For the most current version, please see http://help.sonatype.com

7.5. Policy Creation

Policy can be created at three different levels:

  • Root Organization
  • Organization
  • Application

Creating a policy is rather simple:

  1. Click the Manage Applications and Organizations icon figs/web/clm-server-manage-app-org-icon.png on the IQ Server toolbar.
  2. In the sidebar, select the Root Organization or any other organization/application. In the Manage Applications and Organizations area, policies should be displayed.
  3. Click the New Policy button.
  4. Select the various options, and then Click Save.

However, before you begin creating your own custom policies, it’s a good idea to write out the policies you want to create, and think about where in your development lifecycle you may want to enforce available actions.

In addition, there are a few elements that will need to be in place as well:

  • Organizations and applications are set up as desired on IQ Server.
  • Users have been assigned to these organizations and applications with the proper roles to fulfill your security requirements.
  • You have determined the risks that apply to your organization and/or applications.

Over the next few sections we’ve outlined a multi-step, sample process that takes you through the major steps of creating a policy. These instructions follow the process for creating a policy for an organization. This is where most of your policies will be created. However, if you need to create a policy for the Root Organization, or a specific application, just substitute those entities accordingly.

[Note]

If you have access to the Audit and Quarantine features of Nexus IQ for Repository Manager, policies for your repositories are managed at the Root Organization level only. They do not require a specific application or organization.

7.5.1. Step 1: Understand the Policy Intent

Building on items we mentioned in the introduction, a good first step is to think about the intent of the policy we are going to create. Here are some questions to consider:

  • Is this policy for my repositories? Should it be applied to all applications, or should it only be matched against certain ones?
  • What rules do we want to create, or in other words, what components do we not want in our applications?
  • How should the development organization (or organization as a whole) react when violations occur?

These questions are really just the start, but in short you should think about what scenarios should produce a violation, and what action should be taken. For our example policy, we want to focus on a policy that could be used to address architecture, specifically, the Age and Popularity of components our development organization could use, or is already using.

7.5.2. Step 2: Decide on a Descriptive Policy Name

Since architecture is our focus we are going to use it as part of the name for our policy. In addition we are going to add Age and Popularity to the name to be more specific. This will help us later when we start creating additional architecture related policies. Lets go ahead and create this policy:

  1. Log into the IQ Server (by default this is available at http://localhost:8070) using a user account with Owner-level permissions for the organization (a member of the Organization’s Owner Group).
  2. Next, click the Manage Applications and Organizations icon figs/web/clm-server-manage-app-org-icon.png to access the Application and Organization Management area.
  3. In the menu on the left, click on Organizations, and then click the organization you want to add a policy to.
  4. To create a new policy, click the New Policy button. You should now see the policy editing screen (as displayed in Figure 7.4, “Naming the Policy”).
  5. The policy name input field should have focus and contain Enter Policy Name.
  6. Enter the new policy name by typing Architecture Age and Popularity
figs/web/server-policy-naming.png

Figure 7.4. Naming the Policy


7.5.3. Step 3: Choose an Appropriate Threat Level

Threat level is one of the easiest concepts we’ll cover in this chapter, yet it has the greatest chance to cause huge problems. At it’s core, this is simply a value for severity your business associates with a given policy. These values range from 1 to 10, each corresponding to range of severity, and a specific color:

Table 7.1. Threat Levels

High

Red

8-10

Medium

Orange

4-7

Low

Yellow

2-3

Informational

Dark Blue

1

None

Light Blue

0


To assign threat level to a policy, you will need to be in the policy edit mode (click on the editing icon). Next, use the drop down, which is located next to policy screen. This is displayed in Figure 7.5, “Editing the Policy Threat Level”.

figs/web/clm-server-policy-threat-level-edit.png

Figure 7.5. Editing the Policy Threat Level


Threat level also impacts the default display in many IQ Server reports and views. More specifically, any component that has violated a policy will be displayed, ordered by threat level of the violated policy. This is straight forward, but let’s take a look at the details and see where some issues can arise.

Just like taste is subjective, you have to realize that threat level is subjective. What may be a level 10 for one part of the business may be quite different for another.

A bigger concern is what message you want to communicate to the recipients of the analysis. For example members of your team will naturally be inclined, to treat high severity as very important, and critical. If they see too many of these, the prospect of ever making any headway could be impacted in a negative way and you might dismay e.g. your developers to even get started on trying to fix the violations since there are just too many. As with any control mechanism it is probably advisable to be a bit lenient at first and start to get stricter at a later stage, when the worst problems are dealt with. Otherwise you could cause undue stress to development and management teams. The important thing is to keep in mind is how you will assign severity, and the impact it has on those reviewing violations.

Especially in the beginning, our recommendation is to reduce, if not exclude the high severity threat levels altogether. Remember, at the core, this number is purely for ordering how a violation will be displayed to a user reviewing the results of an evaluation (e.g. in the Application Composition Report). Because this needs to be interpreted, the actual value is very subjective. It’s easy to overwhelm members of your team by seeing large numbers of highly severe violations. It might even be reasonable to set severity to the lowest setting for a violation (Low - 1) in the beginning. This way, members of your teams can get used to seeing the results that are produced.

In our example policy, architecture quality is pretty important, but it’s not the most important issue, so we’ll leave the default threat level of 5. This will give us a violation higher up in the display, but it’s certainly not the worst.

[Tip]

Remember, threat level is subjective, and is most useful for ordering violations.

7.5.4. Step 4: Choose the Matching Parameters

There are two key options for matching a policy:

[Note]

One exception exists to the options listed above: In the case of the Root Organization, the option to match all will also include "repositories". This will impact the policies used as part of the Audit and Quarantine features of Nexus IQ for Repository Manager.

Given the ability to create tags, there is an endless amount of refinement that can be done in order to focus a particular policy on a set of applications with similar characteristics. While we won’t get into the creation of tags here, thinking about this as a way to create more finely tuned policy is a good first step.

For now, you can assume pretty generalized architecture requirements for all components. That is, focus on creating a policy that could be used throughout the development organization.

figs/web/iq-server-policy-management-app-matching.png

7.5.5. Step 5: Create Constraints with Conditions

By now, we should know that an easy way to look at conditions is to consider them the if part of an if/then statement. In contrast, a constraint is not part of the statement, but rather a container for conditions. This can come in real handy when you want to consolidate a policy, by grouping similar conditions.

figs/web/clm-server-policy-constraints-and-conditions-example.png

Figure 7.6. Example Constraint


But why do this?

Well, for one thing, it reduces time. Next, because constraints are displayed on the Application Composition Report, along with violations, it becomes easier for a member of your team to process information that is similar. Of course, it also has the added benefit of not having to create hundreds of small, one-off policies.

For example, in our Architecture Age and Quality policy, we may start with two conditions, one for age and one for popularity. This will work, but it’s likely better, especially if we want to expand that later on, we isolate these as separate constraints.

As a good practice, grouping similar conditions is the best way to build your constraints. For our example, we’ll be placing both conditions in the same constraint. Again, this will help de-clutter a multi-policy environment, as well as help someone trying to understand any associated violations displayed in the various views and reports.

To add a contraint:

  1. Click on the Expand/Collapse icon (shaped like a right-facing triangle). It’s next to the Constraint Name and should display Unnamed Constraint.
  2. Once the constraint is expanded, click the Constraint Name field and enter Age and Popularity as the constraint name where the field initially displays Enter Constraint Name.
  3. Using the drop downs and the add (+) button, add two conditions.

    1. Age should be checked to be older than the value of 3 Years.
    2. Relative Popularity (Percentage) should be set to be greater than or equal to (>=) 50 percent (50%).
  4. Select All in the drop down below the conditions as the aggregating rule so that all of the above conditions have to be fulfilled to trigger a policy violation for the constraint.
figs/web/clm-server-policy-constraints-and-conditions.png

Figure 7.7. Adding Constraints


Now, before we move on, let’s take a look at some of the specific aspects of conditions that can tend to be a bit confusing.

Policy Type. A simple algorithm is used to automatically determine the type of policy you created. It is based on the types of conditions you include and is mainly used for reporting purposes. The rules to determine the type of a policy are:

  • If there are any security conditions, it is considered a security type policy.
  • If there are any license conditions, it is considered a license type policy.
  • If there are any age or popularity conditions, it is considered a quality type policy.
  • If there are any conditions not mentioned above, it is considered an other type policy.

Any vs. All. If a component meets any constraint, the policy is considered violated. However, inside each constraint, when you have more than one condition, you have the ability to require that a component must either meet all conditions or just any of the conditions to trigger a violation.

This is a straightforward concept, but it can produce vastly different results. For example, selecting Any as an option will tend to produce a lot more violations, it’s the equivalent of placing an or between each condition. In addition even if you resolve one violation for a component, if the component meets other conditions later on, it might cause it to still violate the policy. On the other hand, using All' allows you to establish that all conditions must be met. It’s like placing an and between each condition. In this case, if you address any of the conditions, the violation will be resolved.

Let’s look at an example that would further explain this, and then we will move on to creating conditions in our policy. Below, we have a couple of policies and a component. If we wanted to exclude components that were younger then four years and had less than fifty percent popularity, which would we want to use? Also, would the component listed violate this policy?

Policy 1 with Conditions
  • Age is < 4 years
  • Relative Popularity is ⇐ than 50%
  • Any of the above conditions trigger the constraint.
Policy 2 with Conditions
  • Age is < 4 years
  • Relative Popularity is ⇐ than 50%
  • All of the above conditions trigger the constraint.
Component Data
  • Age is 3 years
  • Relative Popularity is 85%

It may seem like these two policies are exactly the same, but there is a key difference, Any vs. All. So, our first policy states that if Any of the conditions are met that a violation will occur. Given that, our component violates this policy. This is good, but we only want a component to violate a policy when Age is less than three years, and popularity is below 50%. We understand that there may be circumstances where a component might need to fall outside one of those boundaries, but if it’s both, we know we have a problem. Our component is pretty popular, so it might be a case where this component, even though it is newer than we prefer, actually resolves an issue another component might have. For this reason, the best policy for us to choose is Policy 2, and our component would not actually cause a violation.

Available Conditions
The following list enumerates the available conditions and describes the operator and the value used for the evaluation.
Age
Verify if the components age based on the date it was placed in the Central Repository in months, days or years is older our younger than a specified value.
Coordinates

Verify if the coordinates for a component match or do not match (e.g. groupId:artifactId:version).

The coordinates may be fixed, or a wildcard can be used. For example, org.sonatype.com:nexus-indexer:1.*. Here, components with a groupId of org.sonatype.com, an artifactId of nexus-indexer, and any version starting with 1. would be matched.

[Note]

This condition is only applicable for Maven components.

Additional Examples
  • A fixed coordinate: org.sonatype.nexus:nexus-indexer:1.0
  • A wildcard coordinate to an inclusive group and version: org.sonatype*:nexus-indexer:1.* - this condition would match, for example org.sonatypetest or org.sonatype.example, an artifact named nexus-indexer in these groups, and any version that starts with 1. for those groups and that specific artifact.
[Note]

The use of the wildcard is limited to the end of each parameter in the coordinate.

Identification Source
Verify if the component identification is or is not based on data from Sonatype or your Manual identification
Label
Verify if a label with a specific label name is or is not attached to a component
License
Verify if the component license is or is not a specified license. If the component license has been overridden, anything listed as declared or observed will be ignored. If license status is not overridden, then any occurrence of the selected license (observed or declared) will be considered a violation.
License Threat Group
Verify if the components license is or is not in one of the groups Banned, Copyleft, Liberal, Non Standard, Not Observed or Weak Copyleft. If the component license has been overridden anything listed as declared or observed will be ignored. If license status is not overridden, then any occurrence of the selected license (observed or declared) in the selected License Threat Group, will be considered a violation.
License Threat Group Level
Verify if the components license threat in its license threat group is either lesser <, lesser or equal <\=, greater > or greater or equal >= a specified value. Value range from zero for no threat to the highest threat level value of ten.
License Status
Verify if the user defined License Status is or is not one of the possible values of Open, Acknowledged, Not Applicable or Confirmed.
Match State
Verify if the match of the comparison of the component to known components from the Central Repository with the same coordinates is or is not exact, similar or unknown.
Proprietary
Verify if a component is or is not considered proprietary.
Relative Popularity (Percentage)
Verify if a the relative popularity of the component version as compared to other versions of the same component group and artifact parameter is either lesser <, lesser or equal <\=, greater > or greater or equal >= a specified percent value.
Security Vulnerability
Verify if a security vulnerability is present or absent. Keep in mind that just because there is no known, or present, security issue, doesn’t necessarily mean none exists.
Security Vulnerability Severity
Verify if a security vulnerability with a numeric severity is either lesser <, lesser or equal <\=, greater > or greater or equal >= a specified value.
Security Vulnerability Status
Verify if a the components security vulnerability status is or is not one of the possible values of Open, Acknowledged, Not Applicable or Confirmed.

Now that you know about all the available conditions and how they can be combined to match all or any condition to create a constraint we are ready to determine what should happen if a constraint is met - the policy actions.

7.5.6. Step 6: Set Policy Actions And Notifications

Policy actions and notifications allow you to perform a specific function when violations occur. In some cases this can include forcing a particular action in one of tools that interact with the IQ Server (e.g. Nexus Pro+.

Alternatively, notifications can be set so that when violations occur, any combination of particular email addresses, or the email addresses associated with the members of a particular role, will be notified.

Actions. Actions are organized by enforcement point, and enforcement points simply represent a stage in the development lifecycle of an application (e.g. Development).

For each stage there are two degrees of action you can assign to each enforcement point:

  • Warn - generally will not break the process, and only displays violations that have occurred (e.g. in Firewall a warning during staging is displayed).
  • Fail - generally will break the process (e.g. in Firewall the release could be prevented).

To add actions:

  1. First make sure you have:

    1. The policy open (have clicked the edit icon - shaped like a pencil).
    2. A minimum of owner rights (a member of the owner role) for the application or organization the policy resides in.
  2. Next, click on either the warn or fail action in the column for the particular stage. An icon will confirm your selection.
  3. Click Save, or proceed to adding notification in the next section.
figs/web/server-policy-actions-example.png

Figure 7.8. Policy Actions Example


[Tip]

Take care in being too anxious to stop your development cycle using Fail.

Notifications. When a new violation occurs, a notification will be sent. This includes any email addresses entered manually, as well as email addresses for the users that have been added to any roles selected.

To add notifications:

  1. Click anywhere within the notifications field. This will display a modal allowing you to select a role or enter a specific email address.
  2. Enter an email address manually, and or select any roles you wish to be notified.
  3. Click Save.
figs/web/clm-server-policy-notifications-example.png

Figure 7.9. Policy Notifications Example


[Note]

When a notification is sent, it will only display new violations found in the latest evaluation. If you find yourself not receiving notifications, verify there are new violations, as well as confirm you have configured your IQ Server SMTP settings.

Stage. Both actions and notifications are set by stage. Each stage represents a point in the development lifecycle. If you have connected the IQ Server with an external tool (e.g. Nexus Pro+) the action and notification can be applied and could have direct effect on the tool. For example, a release can be prevented in Nexus Pro+). To better understand how actions and notifications can be used, a suggested action has been provided for each stage.

Proxy
Suggested Actions

Proxy refers to "Proxy Repository", or the point where components enter your repository manager. This is also referred to as the repository integration point. For more information on how to use the repository integration point, please review the Nexus IQ for Repository Manager chapter.

When setting actions, Warn will have no effect on what happens to components in the repository. However, if you have enabled Quarantine on a repository, and set the action to Fail, any new components added to the repository will be quarantined (unavailable via the Repository Manager).

[Warning]

Quarantined components will not be available to your development team, including any attempt to build existing projects using those components.

Notifications
While notifications can be configured for the Proxy stage, no notifications will be sent. If you have a Firewall license, you can view any policy violations that occur during this stage in the Repository Results.
Develop
While actions and notifications can be configured for this stage, they will not affect the functionality of Eclipse.
Build
Suggested Actions
As you manage policy, making necessary adjustments over time, it’s best to take an approach that allows for your development teams to be eased into dealing with violations. For this reason, it’s better to start by simply warning when the build for an application contains components that violate your policies.
Suggested Notifications
Consider setting up notifications to both inform Application Owners, as well as developers.
Stage Release
Suggested Actions
Because this stage gives the opportunity to prevent an application from being released with components that have violated policy, setting the action for a Stage Release to Fail is our recommendation. This is especially true for any policies that may include risk associated with security and/or licensing.
Suggested Notifications
If something fails, the development process can’t move forward. Make sure to notify any members of the team responsible for the release of the application and capable of researching and addressing any violations.
Release
Suggested Actions
While there should be the closest scrutiny of policy violations at this point, there will be a similar recommendation to fail a release based on severe violations. In most cases, you should ideally be finding new violations only.
Suggested Notifications

Similar to Stage Release make sure all stakeholders, that is those members responsible for ensuring an application does not go into production with policy violations, are notified.

[Tip]

If you have setup policy monitoring, it is a good idea to monitor your release stage, as this is likely the best representation of your production application.

Operate
Suggested Actions
For this reason, providing any warning or fail actions will not produce any different result.
Suggested Notifications
Typically the application owner, or anyone responsible for ongoing maintenance of an application in production should be notified. However, remember that evaluation in the Operate stage is manual.

7.5.7. Step 7: Setup Policy Monitoring

At some point, the application your team is developing will be out of development, have completed its final build, moved beyond staging, and have been officially released. However, while there shouldn’t be changes to your application that is now considered to be in production, new security vulnerabilities and license issues could arise. To address this, you can monitor individual applications for any new policy violations.

The setup for policy monitoring is straightforward. In general you will likely want to avoid monitoring every single policy. Not only is that a lot of policies to monitor, your signal to noise ratio will be off. That is, you might possibly get a lot of notifications for things like old component, or components that are now unpopular.

That’s not to discourage you from monitoring these policies, they are important too. However, monitoring, and in turn, the notifications that are associated with monitoring are best reserved for policies that deal with elements like security vulnerabilities and license issues - that is, those representing a high level of risk.

First, choose an application to monitor

While you can choose any application to monitor, most people start by monitoring an application in production.

  1. Log into your IQ Server with a user account that has proper permissions to make changes to an application policy (at least a member of the owner group for the application would be required).
  2. Next, click the Manage Applications and Organizations icon figs/web/clm-server-manage-app-org-icon.png to access the Application and Organization Management area.
  3. Click Applications in the menu on the left, and then click on the application you want to monitor.
  4. The Application Management area will be displayed.
figs/web/clm-server-policy-monitoring-app-header.png

Figure 7.10. Access Application Management Area


Great, now you can move on to picking the stage you want to monitor.

Next, choose a stage to monitor
The stages listed in the dropdown are identical to the stages displayed when setting policy actions, with the exception that Proxy cannot be used for monitoring.

In general, if you are going to be monitoring a production application, you will want to choose the stage that represents the most recent data. For our example, we’ll choose Build, but again, you can choose any stage.

  1. First, click on the Policy Monitoring section to reveal the options for selecting a stage to monitor.
  2. Next, using the drop down menu, select the stage you wish to monitor. You will notice this drop down selection completes the sentence, " Monitor the latest scan from CLM stage…"
figs/web/clm-server-policy-monitoring-selecting-stage.png

Figure 7.11. Selecting a stage to Monitor


You are almost there, now all you need to do is add notifications.

Each policy you want to monitor will need to have someone added to the notifications. These are set below the Actions section of each policy.

  1. From the Application Management area, click on the edit button of the policy you want to monitor.
  2. Next, just below the Actions section, click the Email icon to open the Monitoring Notification dialog.
  3. Enter an email address manually, and or select any roles you wish to be notified.
  4. Click Done, and then Save to save your edits.
figs/web/clm-server-policy-monitoring-adding-recipient.png

Figure 7.12. Adding Email Recipient


[Tip]

Remember, you can only edit a policy based on your permissions and where it was created, if you don’t see the edit button for a policy, you either need to adjust your permissions, or switch to the organization the policy was inherited from.

figs/web/clm-server-policy-notifications-example.png

Figure 7.13. Policy Monitoring Notification Example


Congratulations! Your application now has a policy that will be monitored. To monitor more applications and/or policies, simply repeat the steps above.

figs/web/clm-server-policy-monitoring-email-notification.png

Figure 7.14. Sample Email Notification


[Tip]

While it is possible to follow these same steps and set policy monitoring at the organization, or even Root Organization level, you may want to think through that a bit more before blanketing all applications within a particular organization with policy monitoring notifications. In many cases, we find that monitoring is best done on a few, high risk, production applications.

Configuring Notification Times. By default any new notifications for policies that are being monitored will be sent out at 12 AM (per the IQ Server time). If you would like to update this, simply edit your config.yml file for the IQ Server. The lines you will need to look for are as follows:

# Hour of the day(0-23) to schedule Policy Monitoring execution. The
default is midnight.

#policyMonitoringHour: 0

7.5.8. The Final Step: Avoiding Policy Micromanagement

If you recall from the Hierarchy and Inheritance section in the previous chapter, there are three core levels (these match the levels where policy can be created as well):

  • The Root Organization
  • Organization
  • Application

In the case of the Root Organization, policies created at this level (with the exception of policies applied to specific Section 8.3, “Tags”) will be inherited by anything below it (i.e. organizations, applications, and repositories). In the same way any policy created in an organization will be inherited by any attached applications.

As you create policy, consider the various scenarios where the policy can be applied (e.g. repositories and applications). While it’s often a thought to create individual policy in each application, this will inhibit your ability to make wider changes, and should be reserved for those scenarios where very specific policy is needed.

If you do go this route, that is creating application level policies, consider that additional micromanagement is required. In many cases, this increases the opportunity for error. So, keeping them at a minimum, and only for those unique scenarios is ideal.