Skip to Content
Technical Articles
Author's profile photo Morten Wittrock

Check your Cloud Integration naming conventions with CPILint 1.0.4

Version 1.0.4 of CPILint is out and you can get your free copy over on GitHub. What is CPILInt, you ask? CPILint is an open source, command-line tool for SAP Cloud Integration that lets you automate the governance of your integration flows. You do so by choosing rules that you want your iflows to adhere to. The tool then does the heavy lifting of checking your iflows for compliance. CPILint ships with rules covering best practices, security, scripting, connectivity and more. For a lengthier introduction to CPILint, please see this blog post.

The NamingConventions rule is finally here

The main feature of the new release is the NamingConventions rule, which lets you check that your naming conventions for channels, flow steps etc. are being followed. This is the number one most requested CPILint feature, and I’m really happy to finally release it! Let’s jump right in and take a look at some examples.

SAP’s Integration Flow Design Guidelines suggest a number of different naming conventions. One of them states that all HTTP receiver channel names must start with HTTP_RCV_. This is what that naming convention looks like using CPILint’s new NamingConventions rule:

<naming>
    <scheme>
        <starts-with>HTTP_RCV_</starts-with>
    </scheme>
    <message>HTTP receiver channel names must start with HTTP_RCV_</message>
    <apply-to>http-receiver-channel.name</apply-to>
</naming>

Straightforward, right? Add this to your rules file, and CPILint will check all your HTTP receiver channels and verify that their names are compliant.

A NamingConventions rule consists of three things:

  • A naming scheme (i.e. the naming convention that must be followed)
  • The error message that will be displayed, if the naming convention is not followed
  • Which names to check

The same naming rule can be applied to multiple names, and the <apply-to> element can therefore occur more than once. At the moment, there are 55 different names you can check, but not all flow step names are supported yet, for instance. Even more names will be added in future versions of CPILint.

Here’s a slightly more complex example. SAP’s guidelines also state that the names of all participants (that is, senders and receivers) must start with OP_, B2B_ or CP_ (for on-premise systems, business partners and cloud providers, respectively). Here’s how to implement that naming convention in CPILint:

<naming>
    <scheme>
        <or>
            <starts-with>OP_</starts-with>
            <starts-with>B2B_</starts-with>
            <starts-with>CP_</starts-with>
        </or>
    </scheme>
    <message>Participant names must start with OP_, B2B_ or CP_</message>
    <apply-to>sender.name</apply-to>
    <apply-to>receiver.name</apply-to>
</naming>

My last example uses the regular expression naming scheme to make sure that Message Mapping steps don’t use the default name:

<naming>
    <scheme>
        <not>
            <regex>Message Mapping \d+</regex>
        </not>
    </scheme>
    <message>Don't use the default Message Mapping step names</message>
    <apply-to>message-mapping.name</apply-to>
</naming>

For the details of the supported naming schemes and a list of all the names you can check using the NamingConventions rule, please see the CPILint wiki.

Other bits and pieces

CPILint now automatically checks whether you are running the latest version of the tool. When a new version is released, you will be notified that there is an upgrade available.

Previous versions of CPILint did some validation of the rules file, but from version 1.0.4 and onwards, the rules file XML document is properly validated using an XML Schema.

Also, the -tmn-host command-line option, which you use to point the tool at your Cloud Integration tenant, is now simply called -host. If you run CPILint from a script, please make sure to update it accordingly.

There was, unfortunately, a bug in the DuplicateResourcesNotAllowed rule. It would crash the tool at the end of a session if no iflows had been inspected. This has been fixed in version 1.0.4.

To get you started, CPILint now also ships with two sample rules files. You can find them in the samples directory in the root of the installation.

The CPILint project by the numbers

This is the fifth release of CPILint so far. There has been 55 commits to the GitHub repository since the initial commit of version 1.0.0 back in September, 2019. As of version 1.0.4, the tool’s code consists of 116 Java source files containing a total of 4513 lines of code (not counting comments). There are a couple hundred more lines of code in there, most of them XQuery, XML Schema and XSLT.

Wrapping up

That’s it for version 1.0.4 of CPILint. I’m really looking forward to hearing your feedback, especially about the NamingConventions rule! So please give the new version a download, and feel free to share your thoughts in the comments below.

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Alexander Clen Riva
      Alexander Clen Riva

      Hi Morten,

      Great blog post.

       

      I am building an azure pipeline and using CPILint.

      I see currently it is supporting basic authentication. Any plan to include OAuth authentication?

       

      Kind regards,

      Alexander

      Author's profile photo Morten Wittrock
      Morten Wittrock
      Blog Post Author

      Hi Alexander

      Really interesting with the Azure pipeline!

      As for OAuth, it's something I want to add, but I can't really offer a time frame at the moment.

      Regards,

      Morten

      Author's profile photo Ajay Kumar
      Ajay Kumar

      Hi Alexander,

      I was trying to use CPILint in Azure pipeline but I'm stuck in passing the variables, Could you provide any useful link or any doc on the steps to execute?

       

      Regards

      Ajay

       

       

      Author's profile photo Alexander Clen Riva
      Alexander Clen Riva

      Hi Ajay,

      Please, find below an example that may help you.

            - task: CmdLine@2
              displayName: Evaluate SAP CI development naming convention
              inputs:
                script: cpilint -boring -rules "sapci-naming.xml" -host $(sapci-hostname) -username $(cpilint-username) -password $(cpilint-password) -iflows $(iflow-id)
                workingDirectory: 'Tool/cpilint-1.0.4/bin'
      Author's profile photo Ajay Kumar
      Ajay Kumar

      Hi Alexander,

      Thank you for your response, I'm quite new to Azure devops, have a question to ask, may be a silly one, do we need any other setting or runtime to set here, other done uploading the CPILINT code?

      Regards

      Ajay

      Author's profile photo Ajay Kumar
      Ajay Kumar

      Hi Morten,

      I'm exploring CPILINT functionality and I'm running the commands and using the sample rules(naming and misc-rules) that you have provided in the setup. I have couple of questions, I would really appreciate if you can answer those.

      1. What is the format of the rules file to be provided as input and is there any specific location I need to place the file, because when I ran by providing the file path it shows below error.

      Rule File:

      <?xml version="1.0" encoding="UTF-8"?>
      <cpilint>
          <rules>
              <!-- Require that all iflows have a description. -->
              <iflow-description-required/>
              <!-- Don't allow the social media receiver adapters. -->
              <disallowed-receiver-adapters>
                  <disallow>facebook</disallow>
                  <disallow>twitter</disallow>
              </disallowed-receiver-adapters>
              <!-- Don't allow Router steps configured with both XML and non-XML conditions. -->
              <multi-condition-type-routers-not-allowed/>    
              <!-- Message Mapping and XSLT are the two allowed mapping types. -->
              <allowed-mapping-types>
                  <allow>message-mapping</allow>
                  <allow>xslt-mapping</allow>
              </allowed-mapping-types>
              <!-- Make sure that all data store writes are encrypted. -->
              <unencrypted-data-store-write-not-allowed/>
          </rules>
      </cpilint>

      Command:

      2. What is the format of iflow file that it is expecting, is it .zip, .jar or .iflw in the command line?

      Regards
      Ajay

      Author's profile photo Morten Wittrock
      Morten Wittrock
      Blog Post Author

      Hi Ajay

      1) You need to provide the path to where the rules file sits in your local file system. If that happens to be in the same directory that you are running the cpilint command from, you can simply refer to it by name. If not, you need to provide a path. In your case, the file would have to be in the root of the C: drive for that command to work.

      2) The tool expects ZIP files directly exported from Cloud Integration. Also, if you want to point to a directory of files, use the -directory option instead of the -files option.

      Let me know how it works out!

      Regards,

      Morten

      Author's profile photo Ajay Kumar
      Ajay Kumar

      Hi Morten,

      Thanks for the response. When I gave the extension of the rules file as well as the iflow file, the command got executed. 🙂

      Is there any way I can write rules for naming convention to be followed in the groovy script?

      Regards

      Ajay

      Author's profile photo Morten Wittrock
      Morten Wittrock
      Blog Post Author

      Glad to hear it!

      The naming conventions rule does not check Ruby code. It would be possible to have rules that do static analysis on Groovy scripts, but at this point it's not on the drawing board.

      Regards,

      Morten

      Author's profile photo Ajay Kumar
      Ajay Kumar

      Hi Morten

      Thanks for the response.

      Ajay