generated from surface-security/django-app
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: initial Github application #1
Open
bogdanoniga
wants to merge
8
commits into
main
Choose a base branch
from
develop
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f576a7c
feat: initial Github application
bogdanoniga 77f9aed
chore: remove unnecessary files/code
bogdanoniga 7efd188
chore: add remaining files/code
bogdanoniga 581ee1d
chore: remove uneccesarry files
bogdanoniga d8616c2
faet: add test step
bogdanoniga bd8baca
feat: add tox.ini
bogdanoniga 3d55234
add pytest.ini
bogdanoniga bb8df3b
chore: add setup.py
bogdanoniga File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include README.md | ||
include LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.PHONY: style | ||
style: | ||
black --target-version=py311 \ | ||
--line-length=120 \ | ||
--skip-string-normalization \ | ||
django_github testapp setup.py | ||
|
||
.PHONY: style_check | ||
style_check: | ||
black --target-version=py311 \ | ||
--line-length=120 \ | ||
--skip-string-normalization \ | ||
--check \ | ||
django_github testapp setup.py | ||
|
||
test: | ||
testapp/manage.py test $${TEST_ARGS:-tests} | ||
|
||
coverage: | ||
PYTHONPATH="testapp" \ | ||
python -b -W always -m coverage run testapp/manage.py test $${TEST_ARGS:-tests} | ||
coverage report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,34 @@ | ||
# Django App | ||
# Django Github | ||
|
||
This template should be used for Django Applications open sourced under the Surface Security context and organization. | ||
Ingest Github organisation and repositories data. | ||
|
||
This template contains some sample workflows, as well as a typical structure of these type of repositories, following companion documentation to help you set it up and get started. | ||
## Integration | ||
The integration utilises Github App to authenticate against Github and extends the `inventory.Integration` model with Github specific fields such as `app_id`, `app_installation_id` and `organisation`. | ||
|
||
# Usage | ||
## Actions | ||
The following Integration actions are available in this application: | ||
- `Users` - Ingests organisation users and teams; | ||
- `Repositories` - Ingests organisation repositories; | ||
- `Codeowners` - Extracts repository owners managed in [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) file; | ||
- `Findings` - Ingests Github Advance Security vulnerabilities. | ||
|
||
READMEs should have extensive and detailed descriptions of how the app should be used, ideally followed with screenshots and/or videos demonstrating the purpose of the app and or service offered. | ||
## Commands | ||
> ./manage.py github_organisation_resync | ||
> ./manage.py github_repositories_resync | ||
|
||
This section should cover everything related to **the end user**, from installing, to descriminate configuration variables users can tweak (if applicable). | ||
## Usage | ||
Add `django_github` to `INSTALLED_APPS` in your `settings.py`. | ||
|
||
# Contributing | ||
To adjust the django application dependencies add the following in settings and modify per project's needs: | ||
``` | ||
DJANGO_GITHUB_MIGRATIONS_DEPENDENCIES = { | ||
'0001_initial': [ | ||
('inventory', '0001_initial'), | ||
] | ||
} | ||
``` | ||
|
||
READMEs should also provide instructions on how to contribute. How to install a development environment, how to run tests, and so on. | ||
The default migration dependency is: | ||
``` | ||
('inventory', '0001_initial'), | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = '0.0.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
from django.contrib import admin | ||
from django_github import models | ||
|
||
|
||
@admin.register(models.GithubIntegration) | ||
class IntegrationAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'organisation', 'description', '_actions', 'enabled') | ||
search_fields = ('name', 'description') | ||
exclude = ('content_source',) | ||
|
||
def _actions(self, obj): | ||
return ', '.join(obj.actions) | ||
|
||
_actions.short_description = 'Actions' | ||
|
||
|
||
@admin.register(models.GithubRepository) | ||
class GithubRepositoryAdmin(admin.ModelAdmin): | ||
list_display = ('name', 'active', 'url', 'type', 'scan_required', 'sca', 'sast', 'sts', 'integration', 'last_seen') | ||
search_fields = ('name', 'url') | ||
list_filter = ( | ||
'active', | ||
'type', | ||
'scan_required', | ||
'sca', | ||
'sast', | ||
'sts', | ||
('integration', admin.RelatedOnlyFieldListFilter), | ||
) | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False | ||
|
||
|
||
@admin.register(models.GithubUser) | ||
class GithubUserAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'name', 'email') | ||
search_fields = ('name', 'email') | ||
readonly_fields = ('id', 'name', 'email') | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False | ||
|
||
|
||
@admin.register(models.GithubTeam) | ||
class GithubTeamAdmin(admin.ModelAdmin): | ||
list_display = ('id', 'name') | ||
search_fields = ('name',) | ||
readonly_fields = ('id', 'name', 'members') | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False | ||
|
||
|
||
@admin.register(models.DependencyFinding) | ||
class DependencyFindingAdmin(admin.ModelAdmin): | ||
list_display = ('number', 'repository', 'state', 'dismissed_reason', 'dismissed_comment', 'url') | ||
search_fields = ('identifiers', 'repository', 'dismissed_reason', 'dismissed_comment') | ||
list_filter = ('apps', 'integration', 'repository', 'severity', 'state', 'first_seen', 'last_seen_date') | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False | ||
|
||
|
||
@admin.register(models.CodeFinding) | ||
class CodeFindingAdmin(admin.ModelAdmin): | ||
list_display = ('number', 'repository', 'state', 'dismissed_reason', 'dismissed_comment', 'url') | ||
search_fields = ('repository', 'dismissed_reason', 'dismissed_comment') | ||
list_filter = ('apps', 'integration', 'repository', 'severity', 'state', 'first_seen', 'last_seen_date') | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False | ||
|
||
|
||
@admin.register(models.SecretFinding) | ||
class SecretFindingAdmin(admin.ModelAdmin): | ||
list_display = ( | ||
'number', | ||
'repository', | ||
'state', | ||
'secret', | ||
'resolution', | ||
'push_protection_bypassed', | ||
'push_protection_comment', | ||
'url', | ||
) | ||
search_fields = ('repository', 'resolution', 'push_protection_bypassed', 'push_protection_comment') | ||
list_filter = ( | ||
'apps', | ||
'integration', | ||
'repository', | ||
'severity', | ||
'state', | ||
'push_protection_bypassed', | ||
'first_seen', | ||
'last_seen_date', | ||
) | ||
|
||
def has_add_permission(self, request): | ||
return False | ||
|
||
def has_change_permission(self, request, obj=None): | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class DjangoGithubConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'django_github' |
Empty file.
Empty file.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to keep these files for consistency with all other projects - unless they're not needed? 🤔