How do I include a custom inspec resource in multiple profiles? - ruby

I have written a custom chef inspec resource to work with a proprietary configuration format that the company I work for uses. I have put the resource in the .\myprofile\libraries folder as the documentation dictates that I should[1]. However, I want to use this resource in multiple profiles without copy/pasting the same resource or symlinking the resource (I'm developing on Windows). Is there a way I can define this resource in a single location and then reference it in multiple profiles?
[1] https://www.inspec.io/docs/reference/dsl_resource/

You can create a profile with your custom resource defined there. I would suggest some profile without any controls, or with minimum amount of controls, which all depend on your custom resource.
Then in the other profiles, where you need your custom resource you can reference your fist profile in inspec.yml:
depends:
- name: my_profile_with_custom_resource
path: ../relative/path
Inplace of path can be an url or a absolute path or git url (with branch and tags). By default all the controls and custom resources defined in my_profile_with_custom_resource will be available in the new profile.

Related

How to provide relative path in Include controller in jmeter for test fragment

I have two thread groups from that in one thread I have two include controllers. but I want to provide relative path instead of absolute path so anyone can use this project in their system. as I am uploading this on GitHub.
enter image description here
If the external .jmx script lives at the same folder - just use its filename like Test Fragment.jmx in the Include Controller
If it resides under a folder - specify its relative location
somefolder/Test Fragment.jmx
For the parent folder:
../somefolder/Test Fragment.jmx
There is includecontroller.prefix property which is being added to the filename specified so if there is a common location for all external JMX files/test fragments you might want to set this property
More information:
Include Controller Documentation
Modularizing for Script Reusability: Examples in JMeter and YAML

I am looking for code policy enforcement tool for xml and Python

I have projects that are developed with xml and python code mostly (Odoo modules). There is a bit of .po files for translation and csv fields for data.
I would like to enforce specific policies in xml files, for example:
No duplicate id attributes.
A specific attribute must be present if child elements contain a specific tags.
On python, I want to enforce rules like:
Look for SQL queries, and make sure that they use specific parameter methods to prevent SQL injection
Follow a specific naming convention
Some attributes are required in classes that inherit a specific class
I hope that the idea is clear.
Is there any open source solution for this? Preferably linked with github and checks on every commit!
I found a python package made specifically for this, pylint-odoo, here.
It can also be installed with pip install pylint-odoo.
An example .pylintrc config file can be found at the web OCA module, here. They also have another file named .pylintrc-mandatory.
There is even a warning for duplicate xml id attribute W7902.

Cannot define shared resource with custom values in TeamCity 10.0.2

There are 3 options available for shared resource type:
Infinite resource
Resource with quota
Resource with custom values
I select Resource with custom values, define them in Custom values field and then save the settings. However, when I open this resource for edit, I see that the resource type went back to "Infinite resource" value.
Is this a bug or feature and does that affect functionality?

How to ensure directory path exists on symlinking in Chef?

Creating a symlink in Chef:
link "#{node[:tomcat][:home]}/webapps/myface.war" do
to "/srv/scafandru/current/myface.war"
end
fails, since at that time the parent directory is missing on the node.
In the link resource I couldn't see any attribute similar to the directory resource's recursive true, so my current approach is to ensure that the directory structure exists by running
directory "#{node[:tomcat][:home]}/webapps" do
recursive true
end
right before linking.
Is there any elegant way to encapsulate this behaviour inside the link resource?
Your solution is the best one if you don't want to write code.
If you are willing to have a better solution, you may extend the provider for link to add the recursive attribute.
To do that, you can refer to opscode documentation that states:
Extending An Existing Provider
If you'd like to write a LWP that
extends another provider class, you can accomplish that as a mixin,
which you would then place in a library under the library directory of
the cookbook using that extended class.
Your LWRP would then be written to include that library in the
provider implementation to get access to the extended core resource.
For an example, see the Transmission Cookbook, which includes a
transmission_torrent_file LWRP that allows you to download a file
via the BitTorrent protocol. This transmission_torrent_file LWRP are
an extension of the existing file and remote_file resources.

Embed external image links in node fields, without downloading them to own site?

In Drupal 7;
I want to show external images in my nodes by giving its link as "http://www.example.com/aa.jpg"
I don't want them to download to my site
I will make it by the fields
Is there a module for Drupal 7 doing this?
Thank you.
In short...yes!
You can install the Media module along with Remote Stream Wrapper module.
When you add your new image field, choose the 'Media file selector' widget. This:
Provides the ability to use external files with file fields without saving the files to your local files directory. Also provides a 'Remote URL' browser plugin.
A further look at the module page for Remote Stream Wrapper says it does this:
By default the module adds support for any URL using http://, https://, or feed://
Which i think is exactly what you're after.
I'd also recommend installing the Media Browser Plus module which provides a better browser for when your users are picking images.
In Drupal 7 you already have Imagecache as a core module. All you have to do is to install Imagecache External. This is an utility module to allow you to use imagecache(D6)/image derivatives (D7) with external images.
After enabling the module, set the following permissions:
View external images
Fetch external images
Configuration
The module's default configuration is very restrictive.
Excluding admin user or users with the 'Bypass black/white list' permission - the default configuration of the module is to deny all requests to fetch external images.
So to get the module to work, you need to visit admin/settings/imagecache_external and either:
Add some domains to the whitelist -or-
Switch the mode of operation from whitelist to blacklist
I hope this helps.
When I follow this procedure I get this error on Remote URL locally
Warning: Invalid argument supplied for foreach() in element_children() (line 6517 of C:\Drupal Sites\BajaInsider\includes\common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5982 of C:\Drupal Sites\BajaInsider\includes\common.inc).
and a dozen other illegal calls for the same variable... Using a NEX theme template as a core. Drupal 7.36, all up to date, no mods to core, testing locally.

Resources