Bug 350856 - Support for Coding checks like MISRA, JSF and Secure coding
Summary: Support for Coding checks like MISRA, JSF and Secure coding
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-codan (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: CDT Codan Inbox CLA
QA Contact: Elena Laskavaia CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 354535
  Show dependency tree
 
Reported: 2011-06-30 11:41 EDT by andy Mising name CLA
Modified: 2015-02-23 21:55 EST (History)
6 users (show)

See Also:


Attachments
Misra email conversation start (1.38 KB, text/plain)
2011-09-08 12:43 EDT, andy Mising name CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description andy Mising name CLA 2011-06-30 11:41:45 EDT
Build Identifier: Indigo

After mail discussion in thread 
http://dev.eclipse.org/mhonarc/lists/cdt-dev/msg22328.html

Support in codan for 
CERT Secure Coding Standards -> https://www.securecoding.cert.org
JSF Air Vehicle - C++ Coding Standards ->http://www.jsf.mil/downloads/documents/JSF_AV_C++_Coding_Standards_Rev_C.doc
MISRA -> http://www.misra.org.uk/

A summary of many styleguides including these exist in "ISO/IEC TR 24772:2010"




Reproducible: Always
Comment 1 Tomasz Wesolowski CLA 2011-07-02 11:19:10 EDT
Only JSF Air Vehicle standard is available online for free, right?
Comment 2 andy Mising name CLA 2011-07-02 12:54:07 EDT
(In reply to comment #1)
> Only JSF Air Vehicle standard is available online for free, right?

Secure is also availabe on the web
https://www.securecoding.cert.org/confluence/display/seccode/CERT+C+Secure+Coding+Standard

and a draft of the TR24772 I found from googling
http://www.aitcnet.org/isai/DocLog/260-thru-279/22-WG23-N-0268/n0268.pdf
Comment 3 Andreas Graf CLA 2011-07-03 04:30:08 EDT
I had investigated the Misra C rules last years (if you are interested, google for "5ise" and "Misra" to find my blog entry on that). The reduplication of Misra rules needs a license from Misra:

<<<
http://www.misra-c.com/MISRACFAQ/tabid/168/Default.aspx
Can I use MISRA C as the basis for a public coding standard or a training course?

Please contact us to discuss licensing terms for such applications. Please note you may not quote rule texts without our written permission.
>>>

Since we are currently forming the Eclipse Automotive Industry Working Group (http://wiki.eclipse.org/Auto_IWG) I check at the next meeting if the participants (currently BMW, Continental, Bosch et. al) if they'd be interested in the topic.
Comment 4 andy Mising name CLA 2011-08-02 04:00:15 EDT
I sent a mail to misra and asked about their opinoin about this and the responce was that it was ok to include the mirsa rule number but not description. They would also like someone to discuss this in the future. Who would be suitable for this? As myself is not a coremember of either eclipse or eclipse automotive.

Currently MISRA C2 is released but this autum a revised version C3 is going to be released. But in my opinoin JSF could also be used as JSF inherits quite mutch on MISRA C2 and exrtends it.

Also the "CERT Secure Coding Standards" is open what I can understand.
Comment 5 Tomasz Wesolowski CLA 2011-08-04 07:02:51 EDT
Implementation suggestions and proposed design:

I strongly recommend against creating those standard conformity checkers as stand-alone checkers (or plug-ins). We need to take into consideration that:
1) the checkers for many (if not most) issues from safe coding standards can be useful (as a whole or selectively) for everyone, not only for people who care about standards conformity,
2) many problems are probably described in many standards (the standard/problem relation is n-n, not 1-n).

On that grounds, I propose the following solution:

1) Implement and distribute all checkers with Codan. Make the restrictive checkers (such as forbidding dynamic allocation) disabled by default and in a separate category, so that they may be enabled on demand.
2) Introduce the notion of a "coding standard" into Codan. Introduce a new Coding Standards preference page, next to enabling/disabling individual problems, to enable or disable enforcing a specific coding standard (as a whole).
3) Let each problem be assignable to coding standards. Let each checker run if at least one of its problems is either:
- enabled on Problems preference page,
- assigned to a coding standard enabled on Coding Standards preference page.

---

Details:

1) Standard variants
Coding standards may come with different versions, conformity levels and severity levels. It must be possible for a problem to be assigned to a standard with given settings (with the exact settings being individual for every standard). For the end-user, it must be possible to not only enable a standard, but also the desired version, desired conformity level (enable all problems with assigned conformity greater or equal to the given), etc - again, the details are standard-specific.

2) Problem preferences
Some problems come with their own specific preferences - be it comment surpression patterns, function name patterns, etc. It should be possible for a problem to be assigned to different coding standards with different sets of preferences.

3) Problem marker labels
If a discovered problem is included in an active coding standard, then the Codan problem message should be adjusted appropriately. At the very least it should contain the rule number. This implies that the exact reported problem text would depend on currently selected coding standards.

Possible extensions:

1) Allow custom coding standards
If a company uses its custom Codan problem settings, it might be useful to save a given set of enabled Codan problems and their preferences, to be re-used among projects. It seems to make sense to treat such setting group similarly to the coding standards that we're going to introduce.

2) Introduce conformity reports
A simple but useful thing to implement is a view which would show some statistics for a project- for example the number of distinct problems described by a coding standard and found in code, next to the number of all problems described in that standard. The ratio of those would be an estimate on how well the project conforms to the standard.

3) Introduce problem description feature
The problem descriptions from coding standards (at least from CERT) are a valuable source of good programming advice. Wherever the licensing allows this, I think that it would be worthwhile to embed those descriptions in the IDE somehow - for example using the Eclipse help system (and possibly with an additional plug-in), also adding easy navigability from problem marker to problem description.
While this may look unimportant, I feel that it would add a lot of value to the IDE, since it's also used by inexperienced programmers who would benefit most from being told not only "this construct is dangerous", but "why".
Comment 6 andy Mising name CLA 2011-08-05 07:11:11 EDT
This sugestion sounds good to me.

Regarding the a link to the description and examples would be very good I agree. Many of the descriptions exist also in CWE I noticed while reading TR 24772

CWE -> http://cwe.mitre.org/

For links to MISRA perhaps one could do so that when one have bought it one could copy it in a directory and eclipse would open pdf and go to right place in doc.

There is a possibility we are allowed to show more from MISRA but that we need to discuss further with them.
Comment 7 andy Mising name CLA 2011-09-08 12:43:57 EDT
Created attachment 203010 [details]
Misra email conversation start
Comment 8 andy Mising name CLA 2011-09-08 12:46:35 EDT
Added as attachment where I stareted the conversation with misra (From may workplace email at wartsila)

A) Who would be best to continue this conversation?
B)If the baseframwork for this is one place I could code a couple of rules my self and commit. In other words wath is the stayus
Comment 9 Erik Shreve CLA 2011-12-03 16:02:41 EST
I'm new to Eclipse, but have an interest in helping develop this feature. Has anything from comment 5 been implemented/prototyped yet?
Comment 10 andy Mising name CLA 2012-09-01 09:07:13 EDT
There exist alsp a coding standard from "JPL Institutional Coding Standard"
http://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf
Comment 11 andy Mising name CLA 2013-02-28 15:36:47 EST
18.3.2013 a new version of MISRA is out..
Comment 12 Andreas Graf CLA 2014-02-03 03:04:37 EST
There is an answer from Misra on MISRA and FLOSS at http://www.misra.org.uk/forum/viewtopic.php?f=56&t=1189
Comment 13 andy Mising name CLA 2014-05-10 02:46:33 EDT
So we can implement the rules and state it's violating e.g "MIRSA 2012: Rule 4.2" then we could open pdf rule from inside eclipse "MISRA-C_2012.pdf" that one have bought for itself and placed on correct place.

Andreas Graf, hadn't you written a couple of rules in codan alreday? Quite soon many companies "summer of code" start and some of the rules could be done that way.
Comment 14 Elena Laskavaia CLA 2015-02-23 21:55:23 EST
I was looking at implementing some checker, but I am confused about rule
"not to include rule text"
what is considered rule text?
They have some kinds of synopsis with a bit of explanation. 
We cannot just include MISRA RULE #X
because developers would not appreciate that.
Did they actually copyrighted these rules some-how?
We have to include some sort of text explaining what the problem is.
We don't have to quote their rule synopsis or rule number at all.