CONTRIBUTING.md 2.56 KB
Newer Older
Nong Hoang Tu's avatar
Nong Hoang Tu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Bashfuscator Contribution Guide

## Style Guide

### Bashfuscator conforms to the PEP8 standard except for a few key differences:

1. Class, function and variable names are camelCase, with class names starting with an uppercase letter. Constant variables are named the normal way, all uppercase with an '_' separating words in the name.

2. Four spaces should be used for indentation instead of tabs.

### Other miscellaneous style rules to follow:

- Always put whitespace between assignment, binary, comparison and Boolean operators:

```python
self.payload += "cat '" + self.workingDir + "'/" + "?" * cmdLogLen + ";"     #good

self.payload+="cat '"+self.workingDir+"'/"+"?"*cmdLogLen+";"                 #not preferred
```

- Always put a blank line before the return statement of any returning function:

```python
def getPrefRange(self, pref):
        if pref == 0:
            min = max = 1
        elif pref == 1:
            min = 1
            max = 2
        elif pref < 4:
            min = 1
            max = pref + 2
        else:
            min = max = 5

        return (min, max)       #notice the blank line before the return
```

- Always put a space before and after parameters when passing multiple parameters to a function:

```python
prefStubs = self.getPrefItems(prefStubs, sizePref, timePref)    #good
prefStubs = self.getPrefItems(prefStubs,sizePref,timePref)      #not preferred
```

- Use double quotes for string whenever possible. Single quoted strings are acceptable if the string contains double quotes inside of it:

```python
if userOb.split("/")[0] == "command":                           #good
if userOb.split('/')[0] == 'command':                           #not preferred

self.payload += 'printf -- "\\x$(printf \'' + randomString      #ok, string contains double quotes
```

- When adding imports to files, make sure the imports are alphabetical, and when possible import only what functions and classes that are needed.

```python
import binascii
from sys import exit        #good
exit(0)

import sys                  #only needed to import sys.exit
import binascii             #not in alphabetical order
sys.exit(0)
```

## Git Guidelines

- Commit early and often. More numerous, smaller commits are prefered to few large ones.
- Write meaningful commit messages. 'Misc tweaks' doesn't describe what was changed at all. When someone needs to go back and find that one commit that broke things, meaningful commit names make the process much less painful.
- Try to accomplish one main thing in each commit. Don't try to fix 5 issues in one commit, or add 3 features either.