Will you please tell me how to set custom phpmd ruleset file in netbeans 8.1? [closed] - netbeans-8

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm installing phpmd into netbeans and it gives me error also but what if I want to set my custom ruleset file in netbeans 8.1?

I got the answer.....
After creating custom standard file using link
place this file to [main][usr/share/data/PHPMD/resources/rulesets]
I make file custom standard rules file name with [bold][customPHPMD.xml]
for that I Write some command on terminal
cd usr/share/data/PHPMD/resources/rulesets
sudo nano customPHPMD.xml
sudo chmod 777 cusomtPHPMD.xml
<?xml version="1.0"?>
<ruleset name="My first PHPMD rule set"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
My custom rule set that checks my code...
</description>
<!-- Import the entire unused code rule set -->
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
<rule ref="rulesets/codesize.xml/NPathComplexity" />
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength" />
<rule ref="rulesets/codesize.xml/ExcessiveClassLength" />
<rule ref="rulesets/codesize.xml/ExcessiveParameterList" />
<rule ref="rulesets/codesize.xml/TooManyFields" />
<rule ref="rulesets/codesize.xml/TooManyMethods" />
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity" />
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
<rule ref="rulesets/controversial.xml/ExitExpression" />
<rule ref="rulesets/design.xml/ExitExpression" />
</ruleset>
after This Rightclick on project->properties->phpcsmd

Related

How do I make .dnn manifest file to create parent node in web.config for my child not if parent node doesn't exist?

I'm working on a DNN module. I need to edit web.config via .dnn manifest file. I need to add rule for url rewrite. I need it to look like this:
<rewrite>
<rules>
<rule name="rule1">
{some content here}
</rule>
<rule name="rule2">
{some content here}
</rule>
</rules>
</rewrite>
So main goal is actually to add 1 rule on install and delete it on module deletion. Here is the code from .dnn file that I tried first:
<component type="Config">
<config>
<configFile>web.config</configFile>
<install>
<configuration>
<nodes>
<!--<node path="/configuration/system.webServer" action="add" collision="overwrite">
<rewrite>
<rules>
</rules>
</rewrite>
</node>-->
<node path="/configuration/system.webServer/rewrite/rules" action="add" collision="overwrite">
<rule name="rule1">
{some content here}
</rule>
</node>
</nodes>
</configuration>
</install>
<uninstall>
<configuration>
<nodes>
<node path="/configuration/system.webServer/rewrite/rules/rule[#name='rule1']" action="remove">
</node>
</nodes>
</configuration>
</uninstall>
</config>
</component>
Problem is that if nodes "rewrite" and "rules" don't exist they are not created and nothing is happening at all on install.
So I tried to add the code that is commented above to create node "rewrite" and "rules" inside of it with collision="ignore" to avoid duplicates. But it doesn't work properly. If "rewrite/rules" exists and it contains already some rules - then DNN thinks that those nodes are different because the existing one contains children and the one that needs to be created has no children. And duplicated "rewrite" is created. Like this:
<rewrite>
<rules>
<rule name="rule_existing_before_module_install">
{some content here}
</rule>
<rule name="rule_added_on_module_install">
{some content here}
</rule>
</rules>
</rewrite>
<rewrite> <!--duplicated nod created by uncommented code-->
<rules>
</rules>
</rewrite>
If I try to add all the nodes at once by wrapping my rule inside "rewrite" and "rules" then it's not merged with existing "rewrite" but instead creates second one and I end up with web.config like this:
<rewrite>
<rules>
<rule name="rule1">
{some content here}
</rule>
</rules>
</rewrite>
<rewrite>
<rules>
<rule name="rule2">
{some content here}
</rule>
</rules>
</rewrite>
So eventually if there was a way to create "rewrite/rules" nodes on condition only if they don't exist and make it work both for node with and without children or make my "rewrite/rules" to merge with existing one - it would solve the problem.
Tried to google - didn't find anything helpful for this case.
Overwriting existing rules with mine and deleting existing rules is not an option.
Currently I'm thinking of manual "rewrite/rules" creation and the rest to leave for module's .dnn manifest file but it's not the best option.
Any suggestions?
P.S. I tried to add existing tag "dnn-module" but editor doesn't find it in tag search for some reason. Maybe a bug because it exists but has no questions so far?
I don't believe that this scenario, is really the targeted goal, as not all installations will actually support this section. (Rewrites is an optional IIS feature, adding this section without it enabled will take a site down)
As such, the current configuration merge functionality doesn't support this exact pathway as you are actually potentially introducing new features/breaking changes so the behavior that it only works with those sections existing is expected.
If you feel that you MUST do this, you could use IUpgradable to have your own custom code modify this, but again, be aware if building for public consumption you run the risk of doing real harm to a site.

IIS Rewrite very confusing

concerning IIS Rewrites.
I want to change this url on my local IIS Instance
http://localhost/MySite/health?key=BczI5MyulpRLxI2kiJmIXwLOm78r3qr8z2gwcsYTGR4=&c
to redirect to this url:
http://localhost/MySite/Health.svc/BczI5MyulpRLxI2kiJmIXwLOm78r3qr8z2gwcsYTGR4=/c
As you can see I don't want the incoming request to use
Health.svc/BczI5MyulpRLxI2kiJmIXwLOm78r3qr8z2gwcsYTGR4=/c
instead to use
health?key=BczI5MyulpRLxI2kiJmIXwLOm78r3qr8z2gwcsYTGR4=&c
The Health.svc is the WCF endpoint name, so I just want /health with the key and filter parameter at the end as shown.
Whatever I put in my web config rewrite it still doesn't work. I am rather confused what bit of the url to put in, as the regex seems to be valid as I can test it in IIS and online regex validators.
<rewrite>
<rules>
<rule name="HealthRewrite" stopProcessing="true" enabled="true">
<match url="MySite\/health\?key=([0-9a-zA-Z=]+)&([a-z])" />
<action type="Rewrite" url="MySite/Health.svc/{R:1}/{R:2}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
How can I get this to work? I have got the rewrite module installed as can see it in IIS an also can see the dll is registered.
If you want to match the value of the query string in IIS, you need to use {QUERY_STRING}. Here is a demo:
<rewrite>
<rules>
<rule name="Test">
<match url="(Service1)" />
<conditions>
<add input="{QUERY_STRING}" pattern="(key)=(.*)" />
</conditions>
<action type="Rewrite" url="Service1.svc/{C:2}" />
</rule>
</rules>
</rewrite>
This is my web.config.
This URL:
http://localhost/Service1?key=getdata
will redirect to this url:
http://localhost/Service1.svc/GetData
For your last question, why add the MySite prefix? This is because the URL in the Rewrite URL will be used as the redirect URL. Notice that it uses back-references to preserve and rearrange the original URL pieces captured during pattern match. For Rewrite, all prefixes other than localhost must be provided in the Rewrite URL.
I managed to get it working with going to all sorts of sites as its not obvious at all.
They key seemed to put the conditions in and then a {QUERY_STRING} with regex which can then create the {C:1} and {C:2} groups that are pushed into the new rewrite
<rewrite>
<rules>
<rule name="HealthRewrite" stopProcessing="true" enabled="true">
<match url="^health" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="key=([0-9a-zA-Z=]+)&([a-z])" />
</conditions>
<action type="Rewrite" url="/MySite/Health.svc/{C:1}/{C:2}" appendQueryString="false"/>
</rule>
</rules>
</rewrite>
I found it confusing knowing what url to match but with a few simplified tests of just ^health I could see more easily and play around with getting the query string parameters. I had to provide the Rewrite with the /MySite/ prefix which is confusing as the match didn't need that!

Rewrite rule to modify dynamic url's

I am trying to create a rewrite rule to modify a dynamic url.
The reference (nie1000857) at the end of the url is the only dynamic part.
"fulldetails?" needs to be inserted as shown below.
https://www.estateagent.net/property-to-rent/nie1000857
https://www.estateagent.net/**fulldetails?**property-to-rent/nie1000857
So far I have:
<rule name="Add fulldetails?" stopProcessing="true">
<match url="^property-to-rent(.?)" />
<action type="Rewrite" url="fulldetails?property-to-rent/"/>
</rule>
However I can't work out how to extract the dynamic part of the url(nie1000857) and add it to the end of the rewrite url.
Any help/advise would be greatly appreciated and apologies if I have missed something obvious within Microsoft's documentation.
I am a total beginner with creating rewrite rules.
Thank you.
I worked it out.
Thought Id post the answer for anyone trying to achieve the same.
<rule name="Add fulldetails?" stopProcessing="true">
<match url="^property-to-rent/(.+)" />
<action type="Rewrite" url="fulldetails?property-to-rent/{R:1}"/>
</rule>

Trying to access UpSource over https via IIS Reverse Proxy returns an empty page

I am currently trying to set up various Jetbrains services for use via https by using an IIS reverse proxy. The complete intended setup should looks somewhat like this:
TeamCity: https://server.company.com -> http://server.company.com
YouTrack: https://server.company.com/youtrack/ -> http://server.company.com:1234/issues/
Hub: https://server.company.com/hub/ -> http://server.company.com:5678/hub/
UpSource: https://server.company.com/upsource/ -> http://server.company.com:9876
I have already gotten this to work, with some difficulty, for TeamCity and YouTrack by using the following configuration:
In IIS, I have a TeamCity website that serves as a redirect. The web.config of that site currently looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Reverse Proxy to TeamCity" stopProcessing="true">
<match url="^teamcity/(.*)" />
<action type="Rewrite" url="http://server.company.com/{R:1}" />
</rule>
<rule name="Reverse Proxy to YouTrack" stopProcessing="true">
<match url="^youtrack/(.*)" />
<action type="Rewrite" url="http://server.company.com:8080/issues/{R:1}" />
</rule>
<rule name="Reverse Proxy to Hub" stopProcessing="true">
<match url="^hub/(.*)" />
<action type="Rewrite" url="http://server.company.com:8082/hub/{R:1}" />
</rule>
<rule name="Reverse Proxy to UpSource" stopProcessing="true">
<match url="^upsource/(.*)" />
<action type="Rewrite" url="http://server.company.com:8081/{R:1}" />
</rule>
<rule name="Reverse Proxy to Collaboration General" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://server.company.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
In addition, I have configured the following server variables as described in the documentation:
HTTP_X_FORWARDED_HOST
HTTP_X_FORWARDED_SCHEME
HTTP_X_FORWARDED_PROTO
However, when trying to access UpSource via https://server.company.com/upsource/, all I get is an empty page titled "Upsource". No error message. Not even a Fav Icon. Accessing UpSource via http://server.company.com:8081/ still works as normal though.
I have also already tried running the following chain of commands:
upsource.bat stop
upsource.bat configure --listen-port 8081 --base-url https://server.company.com:443/upsource/
upsource.bat start --J-Dbundle.websocket.compression.enabled=false
However, that did just caused the problem to change to:
HTTP ERROR: 404
Problem accessing /bundle/starting. Reason:
Not Found
Powered by Jetty:// 9.3.20.v20170531
How can I set up UpSource to work like TeamCity and Hub are already doing?
Any help on this would be greatly appreciated.
With some help of a YouTrack support employee helping with a related YouTrack error, I was able to figure out the reason behind this issue.
The reason is this: When accessing UpSource via https using a path for the redirect, the path needs to be the same in both the http and https variants.
In short, this will not work:
https://server.company.com/upsource -> http://server.company.com:9876
But this will:
https://server.company.com/upsource -> http://server.company.com:9876/upsource
I got this to work by running the following configurational command on the upsource.bat in [InstDir]/bin:
upsource.bat configure --listen-port 9876 --base-url http://server.company.com:9876/upsource
Now I can at the very least connect to and log in to UpSource via https. There's still a problem, but since it's unrelated to the topic of this question, I will create a separate question for it.
Note: on IIS 8.5 set HTTP1.1 at ARR PROXY-Settings. Otherwise the websocket connects, but there's no communication.
upsource v. upsource-2018.2.1291
https://www.jetbrains.com/help/upsource/proxy-configuration.html#IISreverseProxy

url mapping and convert to dll in ASHX file

1) i have a ashx file that pass to this file my parameters, for example :
Edit
now, i want use it as follows:
Edit
2) how to convert ASHX file to dll file and how to use that??!!
tanx!
The iis7 rewrite rules should work for you
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
<rewrite>
<rules>
<rule name="Rewrite">
<match url="^handler/uc=(.*)&Method=(.*)" />
<action type="Rewrite" url="usecasehandler.ashx?uc={R:1}&method={R:2}" />
</rule>
</rules>
</rewrite>