the policy documentation for imagemagick isn't very broad unfortunately, so i wanted to know whether it is possible to disable all codecs except one. Is this possible? Maybe by rule interpretation order where the second policy overrules the first one like this:
<policy domain="coder" rights="none" pattern="*" />
<policy domain="coder" rights="read | write" pattern="jpeg" />
I can think of several possibilities for this:
in the same file, second rule below first rule
in different files according to the configuration load order
It seems there is only the asterisk-globbing available in patterns, not other regex-style matching or negation (pattern="not jpeg" or something).
You should not attempt wildcard pattern matching, but be explicate about all coders. Luckily, ImageMagick's identify utility, and it can tell you all the coders available in the system's library.
identify -list Coder
Which you can run through awk/sed, and other one-liner utilities to generate a policy map.
<policymap>
<policy domain="coder" rights="none" pattern="BGR" />
<policy domain="coder" rights="none" pattern="BMP" />
<policy domain="coder" rights="none" pattern="BRAILLE" />
<policy domain="coder" rights="none" pattern="CALS" />
<policy domain="coder" rights="none" pattern="CMYK" />
<policy domain="coder" rights="none" pattern="DDS" />
<policy domain="coder" rights="none" pattern="DNG" />
<policy domain="coder" rights="none" pattern="DOT" />
<policy domain="coder" rights="none" pattern="EPT" />
<policy domain="coder" rights="none" pattern="FAX" />
<policy domain="coder" rights="none" pattern="FITS" />
<policy domain="coder" rights="none" pattern="GIF" />
<policy domain="coder" rights="none" pattern="GRADIENT" />
<policy domain="coder" rights="none" pattern="HTML" />
<policy domain="coder" rights="none" pattern="ICON" />
<policy domain="coder" rights="none" pattern="INLINE" />
<policy domain="coder" rights="none" pattern="JBIG" />
<policy domain="coder" rights="none" pattern="JP2" />
<policy domain="coder" rights="read | write" pattern="JPEG" />
<!-- ... -->
<!--
Other coders omitted so folks don't copy-n-past, and assume "job-done"
-->
</policymap>
And of course, repeat with identify -list Format, and identify -list Delegate.
But why not a pattern?
My argument is this. If you author a clever pattern today, what happens when business requirements change tomorrow? I imagine that the policy map will grow in complexity.
What happens if there's a revision in two years? Attempting to read & remember what the pattern is doing will take way more time then three key-stokes in vim.
Related
I am new to office addins. I want to add the environment variable. As in the below manifest code, we can see that the URL http://localhost:3000/ is repeated again and again. I want to store this URL in any specific place or in any file and after that, I want to use it in the manifest file. So, whenever I change the URL it will reflect all the places. We don't require to change at all. I am not getting any idea about it.
so can anyone guide me on "How to use a single URL in the manifest with an environment variable?"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0" xmlns:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="TaskPaneApp">
<Id>083aced0-1978-4026-bfb3-86e91ecdf2ec</Id>
<Version>1.0.0.0</Version>
<ProviderName>Test Excel Add-in</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Test Excel Addin" />
<Description DefaultValue="A template to get started." />
<IconUrl DefaultValue="https://localhost:3000/assets/Favicon-36px.jpg" />
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/Favicon-36px.jpg" />
<SupportUrl DefaultValue="https://test.zendesk.com/hc/en-us" />
<AppDomains>
<AppDomain>https://demo.test.test</AppDomain>
<AppDomain>https://test.test-const.net</AppDomain>
</AppDomains>
<Hosts>
<Host Name="Workbook" />
</Hosts>
<DefaultSettings>
<SourceLocation DefaultValue="https://localhost:3000/taskpane.html" />
</DefaultSettings>
<Permissions>ReadWriteDocument</Permissions>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
<Hosts>
<Host xsi:type="Workbook">
<DesktopFormFactor>
<GetStarted>
<Title resid="GetStarted.Title" />
<Description resid="GetStarted.Description" />
<LearnMoreUrl resid="GetStarted.LearnMoreUrl" />
</GetStarted>
<FunctionFile resid="Commands.Url" />
<ExtensionPoint xsi:type="PrimaryCommandSurface">
<OfficeTab id="TabHome">
<Group id="CommandsGroup">
<Label resid="CommandsGroup.Label" />
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Control xsi:type="Button" id="TaskpaneButton">
<Label resid="TaskpaneButton.Label" />
<Supertip>
<Title resid="TaskpaneButton.Label" />
<Description resid="TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<TaskpaneId>ButtonId1</TaskpaneId>
<SourceLocation resid="Taskpane.Url" />
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/Favicon-36px.jpg" />
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/Favicon-36px.jpg" />
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/Favicon-36px.jpg" />
</bt:Images>
<bt:Urls>
<bt:Url id="GetStarted.LearnMoreUrl" DefaultValue="https://go.microsoft.com/fwlink/?LinkId=276812" />
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html" />
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html" />
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GetStarted.Title" DefaultValue="Get started with test Add-in" />
<bt:String id="CommandsGroup.Label" DefaultValue="Commands Group" />
<bt:String id="TaskpaneButton.Label" DefaultValue="test" />
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="GetStarted.Description" DefaultValue="test Add-in Loaded Successfully" />
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="test Add-in Taskpane" />
</bt:LongStrings>
</Resources>
</VersionOverrides>
</OfficeApp>
The URLs in the manifest.xml file cannot change after the manifest has been uploaded to Microsoft AppSource (aka "the Store") or uploaded using Centralized Deployment in the Microsoft 365 Admin portal. It is not possible to store the URLs outside of the manifest.xml file once the manifest has been published or deployed.
You can change how the manifest.xml file is generated by modifying the webpack.config.js file in your add-in project by changing the following code:
plugins: [
...
new CopyWebpackPlugin({
patterns: [
...
{
from: "manifest*.xml",
to: "[name]" + "[ext]",
transform(content) {
if (dev) {
return content;
} else {
return content.toString().replace(new RegExp(urlDev + "(?:public/)?", "g"), urlProd);
}
},
},
],
}),
Typically in Node based applications you could store environment variable in ENV files in the following way:
# .env file
USER_ID="239482"
USER_KEY="foobar"
NODE_ENV="development"
And read them in your application when required:
require('dotenv').config();
process.env.USER_ID; // "239482"
process.env.USER_KEY; // "foobar"
process.env.NODE_ENV; // "development"
And you can do so in Office web add-ins.
But add-in manifest files are processed by the webpack and the final URL depends on the configuration of webpack where you can specify the release and debug URLs and depending the build conditions the required manifest file will produced with the right URL. If you use VSCode and Yeoman generator was used to scaffold the project, in the webpack.config.js file you may find the following declarations:
const urlDev = "https://localhost:3000/";
const urlProd = "https://www.contoso.com/"; // CHANGE THIS TO YOUR PRODUCTION DEPLOYMENT LOCATION
In the file you may find the code which replaces the localhost entries in your manifest file with the production URL specified in the code (see urlProd).
new CopyWebpackPlugin({
patterns: [
...
{
from: "manifest*.xml",
to: "[name]" + "[ext]",
transform(content) {
if (dev) {
return content;
} else {
return content.toString().replace(new RegExp(urlDev, "g"), urlProd);
}
},
},
],
}),
That is done by the webpack. You don't need to replace URLs manually in the manifest file.
I have Nlog configuration in the web config file and I would like to change the file path in the CD pipeline in order to put some dynamic path based on the environment.
Right now the web.config file variable substitution (XML Variable Substitution option) does not support it.
What are the other ways this can be done? I really don't have a choice to go the Web.Config transformation approach.
Any guidance on this will really help.
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true"
throwExceptions="false"
internalLogLevel="Error" internalLogFile="c:\Logs\nlog-internal.log">
<targets name="nlogconfig" async="true">
<target xsi:type="File" name="name"
fileName="Path/${shortdate}.log"
archiveFileName="Path/${shortdate}.{###}.log"
layout="${longdate} ${uppercase:${level}} ${callsite:className=true:includeSourcePath=true:methodName=true:skipFrames=1:cleanNamesOfAnonymousDelegates=true} ${newline} ${message} ${newline} ${exception:innerFormat=ToString:maxInnerExceptionLevel=2:innerExceptionSeparator=newline:separator=newline:format=ToString,StackTrace}${newline}"
archiveAboveSize="8388608"
archiveNumbering="Rolling"
archiveEvery="Day"
concurrentWrites="true"
maxArchiveFiles="100" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="name" />
</rules>
</nlog>
What are the other ways this can be done?
You could use the Replace Token task from Replace Tokens Extension.
Here are my steps, you could refer to them:
Nlog configuration:
<targets>
<target name="logfile" xsi:type="File" fileName="#{variable}#/#{shortdate}#.log />
<target name="logconsole" xsi:type="Console" />
</targets>
Replace Token task sample:
- task: replacetokens#3
inputs:
rootDirectory: 'Folder Path'
targetFiles: '**/*.config'
encoding: 'auto'
writeBOM: true
actionOnMissing: 'warn'
keepToken: false
tokenPrefix: '#{'
tokenSuffix: '}#'
useLegacyPattern: false
enableTelemetry: true
Variable:
Then the variables in Nlog configuration will be replaced.
Alternative solution is to deploy an environment-specific override-file next to the default NLog.config.
Example of environment-specific NLog.override.config:
<nlog>
<variable name="LogDirectory" value="D:/Path" />
</nlog>
Example of NLog.config:
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<variable name="LogDirectory" value="${basedir}" /> <!-- Default Value -->
<include file="NLog.override.config" ignoreErrors="true" /> <!-- Override Value -->
<targets async="true">
<target xsi:type="File" name="name" fileName="${LogDirectory}/${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="name" />
</rules>
</nlog>
The deployment-package could include multiple nlog.override.config-files. One for each environment and just deploy the right one based on chosen environment.
See also: https://github.com/nlog/nlog/wiki/Configuration-file#include-files
I've got the following entries in my Web.config file in an asp.net mvc application:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
...
</configSections>
<log4net>
<appender name="PublicAccessAppender" type="log4net.Appender.RollingFileAppender">
<datePattern value="'C:\Users\my_user_name\Documents\Temp\logs\public-access.'yyyy-MM-dd'.log'" />
<staticLogFileName value="false" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<maxSizeRollBackups value="5" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="PublicAccessAppender" />
</root>
</log4net>
...
</configuration>
I hope it's pretty self-explanatory what I'm trying to achieve, but when I run the application (hosted in IIS), I get no log file. FWIW, the directory hierarchy exists up to Temp folder, and I'd like log4net to generate the rest of the directories/files in the path.
I've added the log4net nuget package to my application, and I'm logging with the INFO level.
What am I missing here?
I think you can't put full path into datePattern, there must be just YYYYmmdd and things like that. Put the file path into file element:
<file value="C:\Users\my_user_name\Documents\Temp\logs\public-access.log" />
<datePattern value="yyyyMMdd" />
<preserveLogFileNameExtension value="true" />
The last element forces to put datePattern before the .log extension which was probably your original goal..
Here's the working appender configuration:
<appender name="PublicAccessAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\temp\my_user_name\Documents\Temp\logs\app.log" />
<datePattern value=".yyyy-MM-dd" /><!-- can be omitted as it's the default datePattern value -->
<rollingStyle value="Date" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
</layout>
</appender>
Note to readers struggling with log4net configuration: asp.net hosted in IIS pretty much has 0 write permssions, so the issue you're most likely struggling with is that your web app simply doesn't have permission to write to the log file.
That's what was happening for me, and I noticed it by inspecting the contents of log4net.LogManager.GetRepository().ConfigurationMessages in the debugger after calling .Configure().
I followed this post to give my web app the necessary persmissions to write to the log file (namely Read/Write/Modify).
I need write the response message to a "response.xml" file. And the response should be appended to this file, I set parameter "Append" true, but no use, is completely overwritten every time. Anyone can help me? Thanks and best regards.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="EndpointTest" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full" />
</inSequence>
<outSequence>
<log level="full" />
<send>
<endpoint>
<address uri="vfs:file:///usr/local/wso2esb-4.0.3/Log" format="pox" />
<property name="OUT_ONLY" value="true" />
<property name="transport.vfs.Append" value="true" />
<property name="transport.vfs.ReplyFileName" value="response.xml" />
</endpoint>
</send>
<send />
</outSequence>
<endpoint>
<address uri="http://172.21.13.151:18989/aaadc/services/receiveMsg" format="pox" />
</endpoint>
</target>
</proxy>
Remove the append= true parameter from service level and use with endpoint url
eg:
vfs:file:///usr/local/wso2esb-4.0.3/Log?transport.vfs.Append=true
We are evaluating Sonar and I've set up an Ant task to import my project data into Sonar using the instructions here but my libraries aren't appearing in the libraries view.
Apart from this it is working as all the other information is there.
Maybe I've misunderstood what the libraries element is for in the Ant task? Please can someone tell me what I'm missing?
From my build file:
<target name="sonar">
<sonar:sonar workDir="sonartemp" key="org.example:example" version="0.1-SNAPSHOT" xmlns:sonar="antlib:org.sonar.ant">
<!-- source directories (required) -->
<sources>
<path location="src/common/src" />
<path location="src/commonWidgets/src" />
<path location="src/compositionWidget/src" />
<path location="src/nativeLib/src" />
<path location="src/services/src" />
</sources>
<!-- list of properties (optional) -->
<property key="sonar.projectName" value="Test RPS Composition Import" />
<property key="sonar.dynamicAnalysis" value="true" />
<!-- test source directories (optional) -->
<tests>
<path location="src/common/test" />
<path location="src/commonWidgets/test" />
<path location="src/compositionWidget/test" />
<path location="src/services/test" />
</tests>
<!-- binaries directories, which contain for example the compiled Java bytecode (optional) -->
<binaries>
<path location="src/common/build" />
<path location="src/commonWidgets/build" />
<path location="src/compositionWidget/build" />
<path location="src/services/build" />
</binaries>
<!-- path to libraries (optional). These libraries are for example used by the Java Findbugs plugin -->
<libraries>
<path location="src/common/lib/**/" />
<path location="src/commonWidgets/lib/**/" />
<path location="src/compositionWidget/lib/**/" />
<path location="src/services/lib/" />
</libraries>
</sonar:sonar>
</target>
As far as I know this view only works with maven.
The libraries in the ant task definition are for the static analysis tools like findbugs.
This tab is information only and not needed for anything.